Created
December 20, 2012 16:01
-
-
Save FabienArcellier/4346190 to your computer and use it in GitHub Desktop.
Get 2 lists for odd and even elements of list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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