Prolog's atom trouble and beginner material.
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 b开发者_如何学Gout 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?
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.
精彩评论