:- module(prod_cons,[p/1,q/1],cc(h)). main :- q(X)& , p(X)& , X = [3|_]. p(X) :- ask((X=[N|T],N>0)) -> T=[_|_], p(T). p(X) :- ask((X=[N|T],N=0)) -> T=[]. q(X) :- ask(X=[N,N1|T]) -> N1 is N-1, q([N1|T]). q(X) :- ask(X=[0]).