?

Log in

No account? Create an account

Previous Entry | Next Entry

Programming in Prolog

So I this program that I'm writing in Prolog, for this class I'm taking in Computer Science, which I'm not likely to pass because I let the quarter get ahead of me and this teacher assigns solid 15 - 20 hour programming projects. And I have two classes with him. And they're on the same schedule. But here's the deal with Prolog: it's part functional programming, part declarative logical programming. Mostly the latter. What you're supposed to do is to tell the thing about some relationships between some stuff, and then you ask it a question about that stuff. It goes about zipping through the stuff you told it to find out the possible answers to your question. Like this:


UncleOf(John, Katie).
UncleOf(Phil, Katie).


Then you can write something like is:

IsUncle(Name) :-
UncleOf(Name, _).


So you load that information and that function into the Prolog thinger, and you ask it:

| IsUncle(John).


Yes.

And it'll look and see if there's some relationship of UncleOf/2 which has the specified Name as the first argument. That _ character means that I don't care about the second argument; I don't because one need not know of whom someone is the uncle of in order to be an uncle.

Oh yeah, and my head is melting.

Latest Month

May 2009
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31