repositories
/
cc1516.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
c230ff32ddf78d900a4f17f886817d5c41f4c811
[cc1516.git]
/
examples
/
test.spl
1
map(f, l){
2
if(isEmpty(l)){
3
return [];
4
} else {
5
return f(l.hd) : map(f, l.tl);
6
}
7
}
8
9
plus(x, y){
10
return x + y;
11
}
12
13
foldr(f, acc, l){
14
if(isEmpty(l)){
15
return acc;
16
} else {
17
return foldr(f, f(acc, l.hd), l.tl);
18
}
19
}
20
21
times(x, y){
22
return x * y;
23
}
24
25
main(){
26
[Int] l1 = 1 : 2 : 3 : 4 : 5 : [];
27
var c = foldr(times, 1, l1);
28
print(c);
29
// var d = map(plus(1), l1);
30
}