
parent1(Ch) :- trans(seq(openCh(Ch),
                      seq(conc(produce1(Ch),consume1(Ch)),
                           closeCh(Ch)))).

produce1(Ch) :- trans(seq(send(Ch,msg1),send(Ch,msg2))).

consume1(Ch) :- trans(seq(recv(Ch,Msg1),
                       seq(prolog(write(Msg1)),
                        seq(recv(Ch,Msg2),
                             prolog(write(Msg2)))))).


parent2(List,Ch,Answer) :- trans(seq(openCh(Ch),
                                  seq(conc(produce2(List,Ch),consume2(Answer,Ch)),
                                       closeCh(Ch)))).

produce2([N|List],Ch) :-  trans(seq(send(Ch,N),produce2(List,Ch))).

produce2([],Ch) :- trans(state).


