blob: 340eb6da78bb88c5b90affac9f5f1f52a6ecf823 (
plain) (
blame)
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
32
33
34
35
36
37
38
39
40
|
import int;
append [] ys = ys;
append [x:xs] ys = [x:append xs ys];
flatten [] = [];
flatten [h:t] = append h (flatten t);
isEmpty [] = 1;
isEmpty _ = 0;
hd [x:_] = x;
tl [_:x] = x;
last [x:[]] = x;
last [_:xs] = last xs;
init [] = [];
init [x:[]] = [];
init [x:xs] = [x:init xs];
length_tl i [] = i;
length_tl i [_:xs] = length_tl (add 1 i) xs;
length xs = length_tl 0 xs;
repeat 0 _ = [];
repeat n x = [x:repeat (sub 1 n) x];
map f [] = [];
map f [x:xs] = [f x:map f xs];
take _ [] = [];
take 0 _ = [];
take n [x:xs] = [x:take (sub 1 n) xs];
scan op r [] = [r];
scan op r [a:x] = [r:scan op (op r a) x];
iterate f x = [x:iterate f (f x)];
|