Example



next up previous WS Presentations Main Page
Next: Example Up: Document: ciao Previous: Example

Example

May be transformed into (for systems using when):

:- module(produce,[p/1,q/1],ciao(h)).
:- qload(library(cc_lib)).
p(X) :-
        ask((N^T^(X=[N|T]),N>0),_3) & ,
        (
          ask(nonvar(_3))  ->
             T=[_1|_2],
             p(T)
        ) & .

p(X) :-
        ask((N^T^(X=[N|T]),N=0),_1) & ,
        (
          ask(nonvar(_1))  ->
             T=[]
        ) & .

q(X) :-
        ask(N^N1^T^(X=[N,N1|T]),_1) & ,
        (
          ask(nonvar(_1))  ->
             N1 is N-1,
             q([N1|T])
        ) & .

q(X) :- ask(X=[0],_1) & .



Thu Jan 18 11:29:48 MET 1996 <herme@fi.upm.es>-<webmaster@clip.dia.fi.upm.es>