Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nr_pare([],[]).
- nr_pare([H|T],Out):-
- mod(H,2)=:=1,
- nr_pare(T,Out).
- nr_pare([H|T],[H|Out]):-
- mod(H,2)=:=0,
- nr_pare(T,Out).
- nr_impare([],[]).
- nr_impare([H|T],Out):-
- mod(H,2)=:=0,
- nr_impare(T,Out).
- nr_impare([H|T],[H|Out]):-
- mod(H,2)=:=1,
- nr_impare(T,Out).
- contopire([],[],[]).
- contopire([H1|T1],[H2|T2],[H1|Out]):-
- mod(H1,2)=:=0,
- contopire(T1,[H2|T2],Out).
- contopire([],[H2|T2],[H2|Out]):-
- mod(H2,2)=:=1,
- contopire([],T2,Out).
- solve(List,Z):-
- nr_pare(List,X),
- nr_impare(List,Y),
- contopire(X,Y,Z).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement