X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=tests%2Forg.simantics.scl.compiler.tests%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FMatching.scl;h=9f6c2d0129441d376bbd39784ab375ff24100ef1;hp=f240a1c2bcb533402ec1821980f7a2fa65e9eb59;hb=HEAD;hpb=f8576d4d2b3b30d76db552d624fc9f087b8940bd diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Matching.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Matching.scl index f240a1c2b..9f6c2d012 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Matching.scl +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Matching.scl @@ -1,19 +1,19 @@ - -data List a = Nil | Cons a (List a) - -first :: List Integer -> Integer -//first Nil = 0 :: Integer -first (Cons x _) = x - -reverse :: List a -> List a -reverse l = reverseAux Nil l - where - reverseAux accum Nil = accum - reverseAux accum (Cons h t) = reverseAux (Cons h accum) t - -main :: Integer -main = first (reverse l) - where - l = Cons (1 :: Integer) (Cons (2 :: Integer) (Cons (3 :: Integer) Nil)) --- + +data List a = Nil | Cons a (List a) + +first :: List Integer -> Integer +//first Nil = 0 :: Integer +first (Cons x _) = x + +reverse :: List a -> List a +reverse l = reverseAux Nil l + where + reverseAux accum Nil = accum + reverseAux accum (Cons h t) = reverseAux (Cons h accum) t + +main :: Integer +main = first (reverse l) + where + l = Cons (1 :: Integer) (Cons (2 :: Integer) (Cons (3 :: Integer) Nil)) +-- 3 \ No newline at end of file