Prolog: How to produce a multiple answer output?
Question
Given:
fruitid('Apple', 'Granny Smith', 1).
How would I go about creating the clause:
print_fruit_details(FruitID) :-
Which would output 'Apple' and 'Granny Smith' given the input 1.
Thanks,
JAS
Solution
Try this:
print_fruit_details(FruitID) :- fruitid(X, Y, FruitID), write(X), write(Y).
And welcome to StackOverflow :)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow