repositories
/
cc1516.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5fb6450
)
stupid higher order functions
author
pimjager
<pim@pimjager.nl>
Thu, 23 Jun 2016 07:45:50 +0000
(09:45 +0200)
committer
pimjager
<pim@pimjager.nl>
Thu, 23 Jun 2016 07:45:50 +0000
(09:45 +0200)
examples/higher.spl
patch
|
blob
|
history
diff --git
a/examples/higher.spl
b/examples/higher.spl
index
4fdde0f
..
c1ad6d6
100644
(file)
--- a/
examples/higher.spl
+++ b/
examples/higher.spl
@@
-42,6
+42,16
@@
plus(x, y){
return x + y;
}
+ap(f, x) { return f(x); }
+
+mapF(f, xs) {
+ if(isEmpty(xs)) {
+ return [];
+ } else {
+ return (ap(f, xs.hd)) : mapF(f, xs.tl);
+ }
+}
+
main(){
var x = 5;
@@
-50,7
+60,10
@@
main(){
var plus = \x y->x+y;
var g = map(plus, [1,2,3]);
+ var is = mapF(\f->f(1), g);
//var is = map(\f->f(1), g);
+ var p = g.hd;
+ var q = p(1);
//print("is.hd", is.hd);