next up previous Return to CLIP Main Page
Next: Attributed Variables Up: Document: distrib_imperial Previous: Some Implementation Issues

A Simple Producer/Consumer Program

go(L) :- 
        consumer(L) &,
        producer(3,L).

producer(0,T) :- !, T = [].
producer(N,T) :- N > 0,
        T = [N|Ns],
        N1 is N-1,
        report(N,produced),
        producer(N1,Ns).

consumer(L) :-
        ask(L=[]), !.
consumer(L) :-
        ask(L=[H|T]),
        report(H,consumed),
        consumer(T).

... and the bindings posted to the blackboard

$b(0,[3|$shv(100)])
$b(100,[2|$shv(200)])
$b(200,[1|$shv(300)])
$b(300,[])


<herme@fi.upm.es>-< webmaster@clip.dia.fi.upm.es>
Last updated on Mon Mar 31 21:20:55 MET DST 1997