Created
April 9, 2018 07:09
-
-
Save valkheim/7b0f582bb87ce3ccc2db98732e8be7a7 to your computer and use it in GitHub Desktop.
chameau
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
let rec appartenance f e = match e with | |
|[]-> false | |
|t::q-> if f=t then true else (appartenance f q);; | |
let res = appartenance ["valkheim"] ["valkheim";"niflheim";"muspelheim"];; | |
let rec ajout f e = match e with | |
|[]-> [f] | |
|t::q-> if f=t then e else t::(ajout f q);; | |
let res = ajout "4" ["1";"2";"3"] | |
let rec printl xs = | |
let rec _printl xs i = | |
match (xs,i) with | |
([], i) -> Printf.printf "]\n" ; () | |
| (t::q, 0) -> Printf.printf "[%s" t ; _printl q 1 | |
| (t::q, i) -> Printf.printf ";%s" t ; _printl q i | |
in | |
_printl xs 0; | |
;; | |
printl res | |
let rec inclusion e1 e2 = match e1 with | |
[] -> true | |
| t::q -> if appartenance t e2 then inclusion q e2 else false | |
;; | |
let res = inclusion ["valkheim"] ["valkheim";"niflheim";"muspelheim"];; | |
Printf.printf "inclusion: %b\n" res | |
let egalite e1 e2 = (inclusion e1 e2) && (inclusion e2 e1);; | |
let ret = egalite ["valkheim"] ["valkheim";"niflheim";"muspelheim"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment