Newbie question regarding clause

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Newbie question regarding clause

Curtis Hoffmann
I have the Clocksin and Mellish Programming in Prolog book, and I'm trying to get past all the errors.
One of the programming examples is for a replacement of listing (p. 182).

list1(X) :-
   clause(X, Y),
   output_clause(X, Y), write('.'), nl, fail.
list1(X).

output_clause(X, true) :- !, write(X).
output_clause(X, Y) :- write((X :- Y)).

If I type the question ?- list1(list1).
I get no response back. Am I doing something wrong, or is there something about clause that I don't understand?
I tried checking the archives and didn't see this question asked before.

Thank you in advance.
Curtis

_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Newbie question regarding clause

Paulo Moura-2
clause/2 only works for dynamic predicates.

> On 27 Aug 2017, at 06:14, Curtis Hoffmann <[hidden email]> wrote:
>
> I have the Clocksin and Mellish Programming in Prolog book, and I'm trying to get past all the errors.
> One of the programming examples is for a replacement of listing (p. 182).
>
> list1(X) :-
>   clause(X, Y),
>   output_clause(X, Y), write('.'), nl, fail.
> list1(X).
>
> output_clause(X, true) :- !, write(X).
> output_clause(X, Y) :- write((X :- Y)).
>
> If I type the question ?- list1(list1).
> I get no response back. Am I doing something wrong, or is there something about clause that I don't understand?
> I tried checking the archives and didn't see this question asked before.
>
> Thank you in advance.
> Curtis
>
> _______________________________________________
> Users-prolog mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/users-prolog

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------





_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog