advertisement

Seven languages in seven weeks: My solutions for prolog day 1

I just finished Prolog day1, and really liked it. It is completely different then any languages I ever worked with. But what I really like is that you let the computer solve logical problems. As a kid, and still now, I was fond of solving Zebra Puzzles(logigram in Dutch), and prolog seems to be a perfect languages to solve this kind of puzzles.

Installing prolog on Os X Lion was a breeze, I used homebrew, and just ran

brew install gnu-prolog

which installed gnu prolog 1.4.0.

While running the examples I ran into some problems. I got the error: syntax error: . or operator expected after expression when running the scripts that came with the book.

After some research I found the problem to be in the file header comments:

#---
# Excerpted from "Seven Languages in Seven Weeks",
# published by The Pragmatic Bookshelf……
# .....
#---

is apparently no a valid comment statement for my version of gnu-prolog.

Anyway, here are my solutions:

Books knowledge base

and the query and results in the console:

musicians

and then in the console:

Conclusion
These are not really exiting exercises, but for me it was one of the first time that I had the impression that the computer was solving a problem, instead of me explaining the computer how to solve the problem.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>