joshua
joshua

Reputation: 997

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.

Upvotes: 1

Views: 265

Answers (1)

Jay Joshi
Jay Joshi

Reputation: 888

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.

Upvotes: 1

Related Questions