开发者

Prolog: How to produce a multiple answer output?

开发者 https://www.devze.com 2022-12-20 23:03 出处:网络
Given: fruitid(\'Apple\', \'Granny Smith\', 1). How would I go abo开发者_开发知识库ut creating the clause:

Given:

fruitid('Apple', 'Granny Smith', 1).

How would I go abo开发者_开发知识库ut creating the clause:

print_fruit_details(FruitID) :-

Which would output 'Apple' and 'Granny Smith' given the input 1.

Thanks,

JAS


Try this:

print_fruit_details(FruitID) :- fruitid(X, Y, FruitID), write(X), write(Y).

And welcome to StackOverflow :)

0

精彩评论

暂无评论...
验证码 换一张
取 消