prolog
Prolog - Count the number of leaves in a tree
If I have a tree that for example looks like this: tree3(b(l(1),b(l(2),l(3)))). How would I write a program that counts the number of leaves?[详细]
2023-04-02 09:45 分类:问答Prolog - Balanced tree or not
I want to write a program that tells me if a tree is balanced or not. In this case balanced means same height or a height difference of 1.[详细]
2023-04-02 06:30 分类:问答Prolog: add list to set
The below predicate adds item X to list S.It works fine. addToSet(X, S, S) :- atomic(X), member(X, S), !.[详细]
2023-04-02 05:00 分类:问答Prolog: find the last index of an element in a list
Suppose I have a list [1,2,1,3,2,0,8,3,1],I wa开发者_运维问答nt to find the index of the last 3 which is 7, How to do it in prolog?Something like[详细]
2023-04-02 01:48 分类:问答swi prolog , how to read the data for the txt.file
Can someone help me with my file reading predicate? get_userinfo: write(\'\\nEnter Name:\'), readln(Name),[详细]
2023-04-01 23:06 分类:问答Prolog; a question about notation in an assignment
I get hat isa开发者_Python百科/2 is a rule, that takes two objects or terms. But what would isa2/2 imply? That isa is defined twice? isa2/2 simply refers to a predicate named isa2 taking 2 arguments,[详细]
2023-04-01 19:00 分类:问答SWI Prolog , how to assert data to txt file
This is my sample source code , I am using SWI Prolog , can someone tell me how to assert data that userkey in to txt.file. I want save the data in to txt.file.[详细]
2023-04-01 07:53 分类:问答Prolog: how to do "check(a++b++c++d equals d++a++c++b) -> yes"
Let\'s define custom operators - let it be ++,equals :- op(900, yfx, equals). :- op(800, xfy, ++). And fact:[详细]
2023-04-01 01:12 分类:问答illegal start of term
GNU Emacs 23.2.1 prolog-mode-version is a variable defined in `prolog.el\'. Its value is \"1.22\" I have consulted the following file:[详细]
2023-03-31 15:06 分类:问答Prolog: Decrementing variable in argument
I am new to Prolog and was tasked with a Fibonnaci predicate fib( N, F) where N is the number in sequence, and F is the value.What I came up with does not work, but the solution I found seems identica[详细]
2023-03-30 16:03 分类:问答