Prolog: store solutions in a list -


this simple question ;)


fact(a).

fact(b).

test(x):-fact(x).


the solutions x=a; x=b. ok

i'm trying create: test(x,l):-fact(x), ??? returns l=[a,b]

can me? thanks.

use findall/3 aggregate solutions:

test(l):-   findall(x, fact(x), l). 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -