From 71fdb64eb4784f259bb6651f5039d2c54e2d01e8 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 23 Aug 2025 00:08:39 +0300 Subject: doc: added exercises 3 and 4 --- TUTORIAL.md | 26 ++++++++++++++++++++++++++ solutions/id.slip | 1 + 2 files changed, 27 insertions(+) create mode 100644 solutions/id.slip 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)) -- cgit v1.2.3