Prolog: Error Handling and Find Unique

Posted by anotherstat on Stack Overflow See other posts from Stack Overflow or by anotherstat
Published on 2010-03-04T15:24:53Z Indexed on 2010/04/21 11:53 UTC
Read the original article Hit count: 299

Filed under:
|

Given:

fruitid('Apple', 'Granny Smith', 1).
fruitid('Apple', 'Cox', 2).
fruitid('Pear', 'Bartlett', 3).

How would I go about finding only unique items for instance:

is_unique(FruitName):-

In the example clauses the answer would be Pear.

I'm also trying to add error handling to my code, so in this instance if an input is:

is_unique(pineapple)

How could I catch this and output an error message?

Thanks,

AS

© Stack Overflow or respective owner

Related posts about swi-prolog

Related posts about error-handling