-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlists.mhs
More file actions
31 lines (25 loc) · 799 Bytes
/
lists.mhs
File metadata and controls
31 lines (25 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
value main = maptest
value appendtest = append (Cons One (Cons Two Nil)) (Cons Three (Cons Four Nil))
value reversetest = reverse (Cons One (Cons Two (Cons Three (Cons Four Nil))))
value maptest = map succ (Cons One (Cons Two (Cons Three (Cons Four Nil))))
value head = \ a -> case a of
Cons h tl -> h |
wild -> Error
value tail = \a -> case a of
Cons h tl -> tl |
wild -> Error
value append = \a b -> case a of
Cons h tl -> Cons h (append tl b) |
Nil -> b
value reverse = \a -> case a of
Cons h tl -> append (reverse tl) (Cons h Nil) |
Nil -> Nil
value map = \f l -> case l of
Cons h tl -> Cons (f h) (map f tl) |
Nil -> Nil
value succ = \ a -> case a of
One -> Two |
Two -> Three |
Three -> Four|
Four -> Five |
Five -> Infinity