Showing posts with label prolog. Show all posts
Showing posts with label prolog. Show all posts

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.

Monday, 24 March 2014

Problem #2: "Syntax error: Operator priority clash"



Description

Solution

Replace the comma on the last line with a period.
SWI-Prolog uses the term for illegal sequences of operators. I.e.
a :- b :- c. 
Quoted from: http://www.groupsrv.com/computers/about124076.html 

Comment

Even though I new to Prolog (this is my second program using it), I feel like I'll continue to make this mistake if I ever use Prolog again.