Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Created December 20, 2012 15:51
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/4346111 to your computer and use it in GitHub Desktop.
Save FabienArcellier/4346111 to your computer and use it in GitHub Desktop.
Extrait odd elements from a list
is_pair(X) :- Pair is X mod 2, Pair =:= 0.
is_impair(X) :- Impair is X mod 2, Impair =:= 1.
gpair([],[]).
gpair([T|R], [TP|RP]) :- is_pair(T), gpair(R, RP), TP = T.
gpair([T|R], L) :- is_impair(T), gpair(R, L).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment