From 0a0932f378b317be213b13682ca031c765c39ca7 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 30 Oct 2023 10:14:11 +0100 Subject: [PATCH] vault backup: 2023-10-30 10:14:11 --- .obsidian/workspace.json | 3 ++- Exam.md | 35 ++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 91254a9..780e5b2 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -78,7 +78,8 @@ } ], "direction": "horizontal", - "width": 300 + "width": 300, + "collapsed": true }, "right": { "id": "b83c16dd7908c658", diff --git a/Exam.md b/Exam.md index 3164ed1..07cc218 100644 --- a/Exam.md +++ b/Exam.md @@ -1,16 +1,21 @@ ## Multiple insertion -```Ocaml -let insert_mult n x lst = - if n <= 0 then - invalid_arg "insert_mult: n must be > 0" - else - match lst with - | [] -> [] - | z::f -> - let aux count = function - | [] -> x - | e::t -> - if (count = n) then - e :: x :: t - else aux (count + 1) t - in aux 1 t \ No newline at end of file +``` +# let insert_mult n x lst = + if n <= 0 then + invalid_arg "insert_mult: n must be > 0" + else + let rec aux count = function + | [] -> [] + | e::t -> + if (count = n) then + e :: x :: aux 1 t + else + e :: aux (count + 1) t + in + match lst with + | [] -> [] + | z::f -> z :: aux 0 f + +val insert_mult: int -> 'a -> 'a list -> 'a list = +``` +