In Prolog, given a knowledge base of facts:
someFact(one).
someFact(two).
otherFact(one, two, 123, 456).
otherFact(one, four, 789, 123).
The query setof(X, someFact(X), List).
produces this result:
List = [one, two]
However, the query setof(X, otherFact(one, X,_,_), List
produces this:
List = [two]
While I expected it to produce [two,four]
. Using this source I discovered that typing ;
when the first list is returned will show all the other options:
List = [two] ;
List = [four] .
Why does it do this? Is it because of the underscores? How do I produce a set where both two
and four
is given, without pressing ;
?
I didn't know how to find an answer to this as I have trouble phrasing this problem into a question that produces search results