aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-23 00:08:39 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-23 00:08:39 +0300
commit71fdb64eb4784f259bb6651f5039d2c54e2d01e8 (patch)
tree60cc7e81e0c4ef37ac936290ad241e41df0ca81e
parent32fb9b036575c8b25a5318c7bce7699249990ff5 (diff)
downloadmyslip-71fdb64eb4784f259bb6651f5039d2c54e2d01e8.tar.gz
myslip-71fdb64eb4784f259bb6651f5039d2c54e2d01e8.zip
doc: added exercises 3 and 4
-rw-r--r--TUTORIAL.md26
-rw-r--r--solutions/id.slip1
2 files changed, 27 insertions, 0 deletions
diff --git a/TUTORIAL.md b/TUTORIAL.md
index e0017d6..30e7d62 100644
--- a/TUTORIAL.md
+++ b/TUTORIAL.md
@@ -466,3 +466,29 @@ n saved
> (fibonacci n)
34 : Int
```
+
+
+Exercise 3: Generic functions – the identity
+--------------------------------------------
+
+Write the identity function for any type.
+
+This should make you familiar with typing function
+definitions that contain generics.
+
+
+Exercise 4: Map left / right (integers)
+---------------------------------------
+
+Write functions `map-left` and `map-right` that take a
+coproduct and a function and map the corresponding side of
+the given coproduct using the given function.
+
+Note: the solution is not in the same directory as the rest,
+but you can find implementations for these in the standard
+library.
+
+This exercise will train your abilities to use generics more
+than the last one. You will get familiar with coproducts.
+
+
diff --git a/solutions/id.slip b/solutions/id.slip
new file mode 100644
index 0000000..e0d768e
--- /dev/null
+++ b/solutions/id.slip
@@ -0,0 +1 @@
+(let id (fn x T T x))