This commit is contained in:
2025-10-10 16:31:53 +02:00
parent 7cf158570d
commit bae49d03ec
4 changed files with 38 additions and 0 deletions

BIN
algo/ocaml/.list.ml.un~ Normal file

Binary file not shown.

7
algo/ocaml/cours.ml Normal file
View File

@@ -0,0 +1,7 @@
(*3 : construire une liste*)
let rec f = function
0->[]
|n -> n::f(n-1);;
(*val f:int -> int list =<fun>*)

16
algo/ocaml/list.ml Normal file
View File

@@ -0,0 +1,16 @@
let i arth n a r=
if n<= 0 then
invalid_arg "invalide arg"
else
let rec suite n a =
if n=0 then
[]
else
a::suite(n-1)(a+2)
in suite n a;;
let rec concat l l2 =
match l with
[]->l2
|e::l->e::concat l l2;;

15
algo/ocaml/liste.ml Normal file
View File

@@ -0,0 +1,15 @@
let rec maxprof lst = match lst with
[e] -> e
|e::l -> let m = maxprof l in if e>m then e else m
|[]->failwith "liste vide";;
let rec max2 a l = match l with
[] -> a
|e::l -> if a < e then max2 e l else max2 a l;;
maxprof [3;2;19;4];;