Created
January 24, 2013 07:55
-
-
Save FabienArcellier/4618537 to your computer and use it in GitHub Desktop.
Operations sur les listes
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
hors_de(X,[Y]):- X\==Y. | |
hors_de(X,[Y|R]):- X\==Y, hors_de(X,R). | |
dedans(X,[X]). | |
dedans(X,[X|_]). | |
dedans(X,[_|L]):-dedans(X,L). | |
tous_dif([_]). | |
tous_dif([X|L]):- hors_de(X,L), tous_dif(L). | |
insere(X,_,[],[X]). | |
insere(X,0,L,[X|L]). | |
insere(X,N,[Y|L],[Y|R0]):-N0 is N-1, insere(X,N0,L,R0). | |
ins(E,ELT,[ELT|E]). | |
ins([X1|L1],ELT,[X1|L2]):-ins(L1,ELT,L2). | |
permut([],[]). | |
permut([X1|L1],S):-permut(L1,L3),ins(L3,X1,S). | |
inter([],_,[]). | |
inter([X1|L1],[X2|L2],[X1|LI]):-dedans(X1,[X2|L2]), inter(L1,L2,LI). | |
inter([X1|L1],[X2|L2],I):-hors_de(X1,[X2|L2]),inter(L1,L2,I). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment