is_odd(X) :- 1 is X mod 2. part( _Predicate, [], [], [] ). % if no elements we produce two empty lists part( Predicate, [H|T], [H|T1], T2 ) :- apply(Predicate,[H]), % if the H satifies Predicate part(Predicate, T, T1, T2). % H is added in front of first list part( Predicate, [H|T], T1, [H|T2] ) :- not(apply(Predicate,[H])), % else part(Predicate, T, T1, T2). % is added to the second list square(N, N2) :- nonvar(N), N2 is N*N. square(N,N2) :- var(N), between(0,N2,N), N2 is N*N.