aboutsummaryrefslogtreecommitdiff
path: root/TUTORIAL.md
diff options
context:
space:
mode:
Diffstat (limited to 'TUTORIAL.md')
-rw-r--r--TUTORIAL.md33
1 files changed, 23 insertions, 10 deletions
diff --git a/TUTORIAL.md b/TUTORIAL.md
index c8eaab2..2f4edf8 100644
--- a/TUTORIAL.md
+++ b/TUTORIAL.md
@@ -211,6 +211,12 @@ An empty vector is created by passing its type to nil:
vector : (Int ...)
```
+Two vectors can be concatenated using the `<>`-operator:
+```console
+> (<> (vector 1 2) (vector 3 4))
+(vector 1 2 3 4) : (Vector (Int ...))
+```
+
The standard library provides the function `sum` to
calculate the sum of a vector of integers. Through
type conversions, this works for lists too.
@@ -280,17 +286,24 @@ General recursion
-----------------
General recursion in myslip is achieved through the
-fixed point operator `fix`.
-
-TODO
-
-
-Understanding error messages
-----------------------------
+fixed point operator `fix`. It works the same as in
+the course materials: it takes a function of type
+`(T -> T) -> (T -> T)` as an argument and uses that
+for recursive calls.
-TODO: div zero
-TODO: unclosed parenthesis
-TODO: type errors
+The factorial function could be implemented as such:
+```myslip
+(let fact (fix
+ (fn fact' (Int -> Int) (Int -> Int)
+ (fn n Int Int
+ (case n
+ (1 1)
+ (_ (* n (fact' (- n 1))))
+ )
+ )
+ )
+))
+```
Exercises