Set a return value in prolog

267 Views Asked by At

I am trying to write simple case in mod function of two peano's number in prolog , put some case it give me wrong answer I don't know what is the problem with my code

simple case is if C smaller than D return C

mod(C,D,F):- smaller(C,D) -> mod(C,D,C). 

I don't have output

thank you.

1

There are 1 best solutions below

0
On BEST ANSWER

By simply doing this:-

mod(C,D,C):- smaller(C,D)

It will return C if smaller predicate returns true, that is when C is smaller than D.