diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 0b16cc5..60f81bb 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -98,7 +98,7 @@ "state": { "type": "backlink", "state": { - "file": "Algo/Courses/Chapter 6 - Lists.md", + "file": "Algo/Courses/Chapter 6 - Lists (Exercises).md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -115,7 +115,7 @@ "state": { "type": "outgoing-link", "state": { - "file": "Algo/Courses/Chapter 6 - Lists.md", + "file": "Algo/Courses/Chapter 6 - Lists (Exercises).md", "linksCollapsed": false, "unlinkedCollapsed": true } @@ -138,7 +138,7 @@ "state": { "type": "outline", "state": { - "file": "Algo/Courses/Chapter 6 - Lists.md" + "file": "Algo/Courses/Chapter 6 - Lists (Exercises).md" } } }, diff --git a/Algo/Courses/Chapter 6 - Lists (Exercises).md b/Algo/Courses/Chapter 6 - Lists (Exercises).md index eac99dc..2a26a5e 100644 --- a/Algo/Courses/Chapter 6 - Lists (Exercises).md +++ b/Algo/Courses/Chapter 6 - Lists (Exercises).md @@ -155,6 +155,18 @@ let rec delete x = function if x == e then i else e::delete x i + +(* Correction *) +let rec delete x = function + |[] -> [] + |e::t -> if e = x then + t + else if x < e then + e::t + else + e::delete x t ;; +val delete: int -> 'a list -> list = + ``` ## Exercise 3.3