repositories
/
cc1516.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
bb744073f93001869f02cab88c0479908473a76f
[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
main(){
22
[Int] l1 = 1 : 2 : 3 : 4 : 5 : [];
23
var c = foldr(plus, 0, l1);
24
var d = map(plus(1), l1);
25
}