From a0ba6c4c7536d1673e66d9c09cfed4552a4c4ab0 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 16 Oct 2023 15:07:24 +0200 Subject: [PATCH] vault backup: 2023-10-16 15:07:24 --- .obsidian/workspace.json | 3 +-- Algo/Courses/Chapter 6 - Lists (Exercises).md | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index c669874..340eb50 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -81,8 +81,7 @@ } ], "direction": "horizontal", - "width": 300, - "collapsed": true + "width": 300 }, "right": { "id": "b83c16dd7908c658", diff --git a/Algo/Courses/Chapter 6 - Lists (Exercises).md b/Algo/Courses/Chapter 6 - Lists (Exercises).md index a1abccf..c6ee805 100644 --- a/Algo/Courses/Chapter 6 - Lists (Exercises).md +++ b/Algo/Courses/Chapter 6 - Lists (Exercises).md @@ -246,11 +246,10 @@ val shard = 'a list -> 'a list -> 'a list -> 'a list = ## Exercise 5.1 ```Ocaml -let assos k l = - if (k < 0) then - invalid_arg "k not natural" - else - match l with - | -> failwith "not found" - | (k,y)::t -> y - | _ -> assos k t +let assos k = function + [] -> failwith "not found" + | (k2, v2)::t when k2 = k -> v2 + | (k2, v2):: t when k < k2 -> faiwith "not found" + | e::t -> assoc k t +val assos = 'a -> ('a + 'b) list -> 'b = +```