Aaron (sodabrew) wrote,

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).


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.
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.