Search code examples
prologsuccessor-arithmetics

Set a return value in prolog


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.


Solution

  • 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.