repositories
/
cc1516.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
demo
[cc1516.git]
/
examples
/
old
/
tempTest.spl
1
//Let Int a = 4;//
2
3
//mapP1(xs) {
4
// if(isEmpty(xs)) {
5
// return [];
6
// } else {
7
// return (xs.hd + 1) : mapP1(xs.tl);
8
// }
9
//}
10
//main() {
11
// [Int] x = [];
12
// [Int] y = [];
13
// Int z = a();
14
// x = mapP1(x);
15
// y = mapP1(x);
16
// return a() + 5;
17
//}
18
19
plus(x,y){
20
return x+y;
21
}
22
23
map(f, xs) {
24
if (isEmpty(xs)) {
25
return [];
26
} else {
27
return f(xs.hd) : map(f, xs.tl);
28
}
29
}
30
31
foldr(f, acc, xs) {
32
if(isEmpty(xs)) {
33
return acc;
34
} else {
35
return foldr(f, f(xs.hd, acc), xs.tl);
36
}
37
}
38
39
main() {
40
var f = plus(1);
41
var z = map(f, 1:2:[]);
42
var x = foldr(plus, 0, 1:2:[]);
43
print(x);
44
return;
45
}