Merge branch 'master' of https://github.com/dopefishh/cc1516
[cc1516.git] / examples / higher.spl
index c5bac9e..59bbbf5 100644 (file)
@@ -34,18 +34,32 @@ intList(x){
        }
 }
 
+giveF(){
+    return (\x->x+1);
+}
+
 plus(x, y){
-       return x + y;
+    return x + y;
 }
 
 main(){
     var x = 5;
 
-       var a = plus(3);
-       print("3+5=", a(5));
+    var f = giveF();
+
+    var plus = \x y->x+y;
+
+    var g = map(plus, [1,2,3]);
+    var is = map(\f->f(1), g);
+
+    //print("is.hd", is.hd);
+
+    print("f(4) = ", f(4));
+
+       print("faculty of 5 is: ", foldr(\x y->x*y, 1, intList(5)));
+       print("sum of 1..5 is: ", foldr(\x y->x+y, 0, intList(5)));
+       print("sum of 0..12 but only the evens: ",
+               foldr(\x y->x+y, 0, filter(\x->x%2 == 0, intList(12))));
+
 
-//     print("faculty of 5 is: ", foldr(\x y->x*y, 1, intList(5)));
-//     print("sum of 1..5 is: ", foldr(\x y->x+y, 0, intList(5)));
-//     print("sum of 0..12 but only the evens: ",
-//             foldr(\x y->x+y, 0, filter(\x->x%2 == 0, intList(12))));
 }