Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Created December 20, 2012 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabienArcellier/4346190 to your computer and use it in GitHub Desktop.
Save FabienArcellier/4346190 to your computer and use it in GitHub Desktop.
Get 2 lists for odd and even elements of list
is_pair(X) :- 0 is X mod 2.
is_impair(X) :- not(is_pair(X)).
selec([], [], []).
selec([T|R], [TP|RP], LI) :- is_pair(T), selec(R, RP, LI), TP = T.
selec([T|R], LP, [TI|RI]) :- is_impair(T), selec(R, LP, RI), TI = T.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment