X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=examples%2Fexample.spl;h=03878105a38931fed317fa46dc91aff68c65aa51;hb=1f01e39fb2383aa2c63234d0750c0459fe3de752;hp=e71c2162f4c473f00c81296158134ed198e57b51;hpb=a363f872ee96379d8b0b9b14cb6faec9d74e7e92;p=cc1516.git diff --git a/examples/example.spl b/examples/example.spl index e71c216..0387810 100644 --- a/examples/example.spl +++ b/examples/example.spl @@ -2,14 +2,6 @@ Three ways to implement the f acto rial function in SPL. First the recursive version . */ -Int r = 1; -Char r = 1; -Int r = -1; -Void r = 0; -Bool r = !True; -Bool r = -True; -//var facN = 1; -//var ok = True; facR(n) :: Int -> Int { if (n < 2) { @@ -38,12 +30,12 @@ main ( ) :: Void { var ok = True; while(n<20) { facN = facR (n); - if (facN != factl (n) || facn != facL (n)){ + if (facN != factl (n) || facN != facL (n)){ print (n : facN : facl (n) : facL (n): []); ok=False; } } - print(ok); + //print(ok); } // A list based factorial function @@ -75,12 +67,12 @@ reverse(list):: [t] -> [t] { abs(n)::Int->Int{if(n<0)return -n; else return n;} //swap the elements in a tuple -swap(tuple) :: (a, a) -> (a, a){ - var tmp = tuple.fst; - tuple.fst = tuple.snd; - tuple.snd = tmp; - return tuple; -} +//swap(tuple) :: (a, a) -> (a, a){ +// var tmp = tuple.fst; +// tuple.fst = tuple.snd; +// tuple.snd = tmp; +// return tuple; +//} //list append append(l1, l2) :: [t] -> [t] -> [t] {