views:

41

answers:

1

I am VERY new at Prolog I am looking for any beginner material on Prolog. I am very interested in learning the language. Where' s good place to start? Online preferably

I also am having a bit of trouble writing some code. I need to return a sentence but all I am getting is a list of atoms (i believe that's the term)

ex I get [the, cat, is, pretty] When I would really like to get [the cat is pretty].

writelist(X):-
    write(X), nl.

How can I turn this atom response into just a normal sentence?

+2  A: 

I learned it from learnprolognow.org, it's online, free, and quite good.

As for your sentence question, you'll need to print it word by word. Example:

writelist([]).
writelist([H|T]):-
    write(H),
    write(' '),
    writelist(T).

First you say that writing an empty list does nothing. Then you say that writing a list whose first element is H and the remainder of which is T entails writing the value of H, a space, then writing the rest of the list the same way.

Max Shawabkeh
Thank you very much :D :D :D That seem to do that trick. Also, that site looks very helpful.Thank you once again. I'm glad I found this site.
Sally Walker
Please mark the answer as accepted if this solved your problem completely.
Max Shawabkeh