curry gotcha
[cc1516.git] / examples / passBy.spl
index 552eabe..74acb29 100644 (file)
@@ -1,34 +1,18 @@
-//modify1(s) :: [Char] -> [Char] {
-//    //s.hd = 'a';
-//    s.tl = [];
-//    return s;
-//}//
-
-//modify2(c) :: Char -> Void {
-//    c = 'a';
-//}//
-
-//main() {
-//    var zs = "bar";
-//    var zc = 'b';
-//    var zss = modify1(zs);
-//    modify2(zc);//
-
-//    print("zs was bar, is now: ");
-//    print(zs);
-//    print(", m1 returned: ");
-//    print(zss);
-//    print("\n");
-//    print("zc was 'b', is now: ", zc, "\n");
-//}
+modif(str) :: [Char] -> Void {
+    str.tl.tl.hd = 'z';
+}
 
-modi(t) :: (Int,Int) -> Void {
-    t.fst = 1;
+modifAtom(x) :: Int -> Void {
+    x = 4;
 }
 
 main() {
-    var x = (2,3);
-    print(x.fst);
-    modi(x);
-    print(x.fst);
+    var s = "bar";
+    var y = 1;
+    print("before modif: ", s, "\n");
+    modif(s);
+    print("after modif: ",s, "\n");
+    print("before modifAtom: ", y, "\n");
+    modifAtom(y);
+    print("after modifAtom: ", y);
 }
\ No newline at end of file