Print multiple things

i want to print all the possible match.
for e.g

eat(human,egg).
eat(human,chicken).
eat(human,veg).

match(X,Y) :-
   eat(X,Y).

so if i call match(human,Y). then it should print egg, chicken, veg.

How to do that?

and here 3 match are there but it may possible that uneven no. of items can present.

please help!!!

I made a little SWISH example here.

Your three rules are in the left panel.

There is no need to create a separate rule to get the results you seek.
The query eat(human,Food). will work and is in the lower right panel.

To run the query again click the Run! button which will show the first result, Food = egg
Under the result is a set of buttons, click 10 to see the next 10 results, but since there are only two more results all the results will then be displayed.

HTH

Hi!
You can also use writeln/1, which writes a line, and fail/0, which forces Prolog to backtrack (find all solutions). nl generates a new line.
Cheers :slight_smile:
/JC

eat(human,egg).
eat(human,chicken).
eat(human,veg).

match(X,Y) :-
   eat(X,Y).

go:- 
    match(X, Y),
    writeln(X),
    writeln(Y),
    nl,
    fail.