Tuesday 25 March 2014

Problem #3: Prolog ignoring a predicate



Description

Prolog seems to be ignoring the second checkForPeriods
 

Solution

Prolog tries the  predicates in the order they're listed! Since the first predicate is still valid when C is 0, it gets used and C goes into the negatives. To solve this I just needed to reorder the two.

Comment

This caused me so many headaches. I was trying to do this, but it kept going negative until it ran out of stack. As you can probably tell, I have no background in Prolog. I'm learning it while I use it to complete this program.

No comments:

Post a Comment