X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=examples%2Fexample.spl;h=0bf275e8856ba18c11c0295150a2762ac8d66523;hb=a8348a333a567e5a469d1e5f8ec6c3dafc051c91;hp=ee36ff365032a8a060c26d54407b06b215208919;hpb=42f469bb622f254f8008b064bdb720c72daaf2e3;p=cc1516.git diff --git a/examples/example.spl b/examples/example.spl index ee36ff3..0bf275e 100644 --- a/examples/example.spl +++ b/examples/example.spl @@ -2,10 +2,6 @@ Three ways to implement the f acto rial function in SPL. First the recursive version . */ -var r = 1; -var facN = 1; -var ok = True; - facR(n) :: Int -> Int { if (n < 2) { @@ -15,6 +11,7 @@ facR(n) :: Int -> Int { } } + //The iterative version of the factorial function facl ( n ) :: Int -> Int { var r = 1; @@ -48,7 +45,7 @@ facL (n) :: Int -> Int { } //Generates a list of integers from the first to the last argument -fromTo (from, to) :: Int Int -> [Int] { +fromTo (from, to) :: Int -> Int -> [Int] { if(from <= to){ return from:fromTo(from+1, to); } else { @@ -78,7 +75,7 @@ swap(tuple) :: (a, a) -> (a, a){ } //list append -append(l1, l2) :: [t] [t] -> [t] { +append(l1, l2) :: [t] -> [t] -> [t] { if(isEmpty(l1)){ return l2; } else {