Examples
[cc1516.git] / examples / demo / map.spl
diff --git a/examples/demo/map.spl b/examples/demo/map.spl
new file mode 100644 (file)
index 0000000..ef6cf38
--- /dev/null
@@ -0,0 +1,15 @@
+map(f, xs) :: (a -> b) -> [a] -> [b] {
+    if(isEmpty(xs)) { return []; }
+    else {
+        return f(xs.hd) : map(f, xs.tl);
+    }
+}
+
+printI(i) :: Int -> Void {
+    print(i);
+}
+
+main() {
+    var xs = map(\x-> x+1, [1,2,3,4,5]);
+    map(printI, xs);
+}
\ No newline at end of file