summaryrefslogtreecommitdiff
path: root/test.icl
diff options
context:
space:
mode:
authorCamil Staps2017-01-25 20:03:25 +0000
committerCamil Staps2017-01-25 20:03:25 +0000
commitb1a5542ecf734403bbf439ab7585a5102bd423b8 (patch)
tree4df08d9c00b8c9feaaef2d878c8f5b02baf68ef5 /test.icl
parentFix cgopts comments (diff)
Final commitHEADmaster
Diffstat (limited to 'test.icl')
-rw-r--r--test.icl69
1 files changed, 67 insertions, 2 deletions
diff --git a/test.icl b/test.icl
index 92f7a54..28f09af 100644
--- a/test.icl
+++ b/test.icl
@@ -1,8 +1,73 @@
module test
+//import StdEnv
+from StdOverloaded import class % (..)
+from StdString import instance % {#Char}
+
(+) infixl 6 :: !Int !Int -> Int
-(+) a b = code inline {
+(+) _ _ = code inline {
addI
}
-Start = 10 + 20
+(<) infix 4 :: !Int !Int -> Bool
+(<) _ _ = code inline {
+ ltI
+}
+
+toString :: !Int -> String
+toString _ = code inline {
+ .d 0 1 i
+ jsr ItoAC
+ .o 1 0
+}
+
+toReal :: !Int -> Real
+toReal _ = code inline {
+ ItoR
+}
+
+(/) infixl 7 :: !Real !Real -> Real
+(/) _ _ = code inline {
+ divR
+}
+
+fromto :: !Int !Int -> [Int]
+fromto f t = if (f < t) [f:fromto (f+1) t] []
+
+append :: ![a] ![a] -> [a]
+append [] ys = ys
+append [x:xs] ys = [x:append xs ys]
+
+map :: (a -> b) [a] -> [b]
+map _ [] = []
+map f [x:xs] = [f x:map f xs]
+
+plus a b = a + b
+
+app f a b = f a b
+
+:: Rec = { x :: Int, y :: String, z :: Real }
+toRec x = { x = x, y = toString x, z = toReal (x + x) / 3.0 }
+
+hd [x:_] = x
+last [x] = x
+last [_:xs] = last xs
+length [] = 0
+length [x:xs] = 1 + length xs
+
+div :: !Int !Int -> Int
+div _ _ = code {
+ divI
+}
+
+test :: !Int !Int -> Bool
+test a b = div (a + b) a < b
+
+Start = (length xs, hd xs, last xs)
+where xs = [toString i % (0,1) \\ i <- fromto 1 200]
+
+//Start = (length xs, hd xs)
+//where xs = fromto 1 100 //append (map toRec (fromto 1 100)) (map toRec (fromto 500 1000))
+//Start = [1..100] ++ [500..1000]
+//Start = app plus 1 2
+//Start = map toReal (fromto 1 100)