Prolog Flashcards
In Prolog, the most natural way to express the fact that a lion is a cat is ANSWER.
cat(lion)
In Prolog, the most natural way to express the query “what animals are cats?” is ANSWER.
animal(What), cat(What)
In Prolog, the most natural way to express the rule that “I am an ancestor of you if I am a parent of you” is ANSWER.
ancestor(I, You) :- parent(I, You)
In Prolog, the most natural way to express the rule that “I am an ancestor of you if I am a parent of an ancestor of you” is ANSWER.
ancestor(I, You) :- parent(I, Ancestor), ancestor(Ancestor, You)
(Both lines are one answer)
In Prolog, the expression hi(X, 4) = hi(3, Y) causes X to have the value ANSWER.
3
In Prolog, the expression hi(X, 4) = hi(3, Y) causes Y to have the value ANSWER.
4
In Prolog, the expression hi(X, 4) = hi(3, X) causes X to have the value ANSWER
X will not be bound
In Prolog, the expression [1, 2, 3] = [X | Y] causes X to have the value ANSWER.
1
In Prolog, the expression [1, 2, 3] = [X | Y] causes Y to have the value ANSWER.
[2, 3]
In Prolog, the expression X = [[1,2] | [3,4]] causes X to have the value ANSWER.
[[1, 2], 3, 4]
In Prolog, the expression X = 1 + 2 causes X to have the value ANSWER.
1+2
In Prolog, the expression 2 = 1 + X causes X to have the value ANSWER.
X remains unbound
In Prolog, the expression that would cause an unbound variable X to take on the sum of the values of a bound variable Y and a bound variable Z is ANSWER.
X is Y + Z