From bae49d03ec3e1147406284600a926517a2f7592c Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 10 Oct 2025 16:31:53 +0200 Subject: [PATCH] exo --- algo/ocaml/.list.ml.un~ | Bin 0 -> 4170 bytes algo/ocaml/cours.ml | 7 +++++++ algo/ocaml/list.ml | 16 ++++++++++++++++ algo/ocaml/liste.ml | 15 +++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 algo/ocaml/.list.ml.un~ create mode 100644 algo/ocaml/cours.ml create mode 100644 algo/ocaml/list.ml create mode 100644 algo/ocaml/liste.ml diff --git a/algo/ocaml/.list.ml.un~ b/algo/ocaml/.list.ml.un~ new file mode 100644 index 0000000000000000000000000000000000000000..ff7c2c25dc692aecf5b298932f35f067bcc0d391 GIT binary patch literal 4170 zcmeH~Jxc>Y5QaA~eie#XX^>>ODnSeyNE0H6XeV~sh669=L{HI}$_S#^h<_lB){@$P zAYvney^V+#mWrj$ySIDUq&S;gw*!;iogF5_JUe%L>+a6gnzyw3#^Nt`&s&9``-k&J zF85VjO&#ScmwT<|=kdzL>vi+C#TXkSRWeDF80oMyU{uPgACG4V?8aF6Njk*kh{4~I zhF=oar|p_)k1Iep(gFu#-xFQ2fr1rI1SZUN5I~0Y2q_bogf~`3dS3y;RMIhZcg(2k z)$MI}qipYQa?6s?;FZvl0WfG1HUkY+h*AjJLKw7U2Q;~GI3ZL30jpn25insBVgRa2 zL^Tq?MI9g>aX{9D z!5jlrAxfcRu&f^g030G!04*E?$iMvzaD!T^fQm>$3`kXps73{ZfpPA#p1!CTXQnmOjaUP$W)?;0fZ?SOsAm= zQ3@e!gdt3~;rX)wp*J(vrl^xgy6P*^y!fJo7sMutr-EY4|2Wifpb>)?pQ71G(Vosz IJHFri0Ygr[] + |n -> n::f(n-1);; +(*val f:int -> int list =*) + diff --git a/algo/ocaml/list.ml b/algo/ocaml/list.ml new file mode 100644 index 0000000..2ee47ae --- /dev/null +++ b/algo/ocaml/list.ml @@ -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;; + diff --git a/algo/ocaml/liste.ml b/algo/ocaml/liste.ml new file mode 100644 index 0000000..7f01e54 --- /dev/null +++ b/algo/ocaml/liste.ml @@ -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];; +