X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=examples%2FpassBy.spl;h=74acb2934f7cdb8390909f4a2129b5bee1e6a452;hb=HEAD;hp=552eabe6e09e57d5c78bdc429a91e940fb5df657;hpb=898df0d6d0e370b8e4c77aee3edd29355a43d022;p=cc1516.git diff --git a/examples/passBy.spl b/examples/passBy.spl index 552eabe..74acb29 100644 --- a/examples/passBy.spl +++ b/examples/passBy.spl @@ -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