Prolog - How do I catch an error of incorrect arity? -
not sure if question worded correctly or not, apologies. want create kind of error handling in prolog. example:
fruit(apple, pear). now if user query:
?- fruit(x). how inform user have made error? , homecoming message along lines of:
data should entered in format: 'fruit(x, y)' please check query , seek again.
i don't think that's application programmer's job. prolog systems has feature.
for particular case can create predicate "wrong" arity outputs message:
fruit(_) :- write('data should entered in format: \'fruit(x, y)\' please check query , seek again.'), nl, fail. error-handling prolog try-catch iso-prolog prolog-toplevel
No comments:
Post a Comment