diff options
Diffstat (limited to 'squeen.icl')
-rw-r--r-- | squeen.icl | 79 |
1 files changed, 78 insertions, 1 deletions
@@ -19,7 +19,84 @@ programmer that are only 40% slower than this solution (lqueen.icl). */ -import StdEnv +(&&) infixr 3 :: !Bool Bool -> Bool +(&&) a b + = code { + push_b 0 + jmp_false l1 + pop_b 1 + jsr_eval 0 + pushB_a 0 + pop_a 1 + .d 0 1 b + rtn + :l1 + pop_a 1 + .d 0 1 b + rtn + } + +(||) infixr 2 :: !Bool Bool -> Bool +(||) a b + = code { + push_b 0 + jmp_true l2 + pop_b 1 + jsr_eval 0 + pushB_a 0 + pop_a 1 + .d 0 1 b + rtn + :l2 + pop_a 1 + .d 0 1 b + rtn + } + +not :: !Bool -> Bool +not True = False +not False = True + +(<) infix 4 :: !Int !Int -> Bool +(<) a b = code inline { + ltI +} + +(>) a b :== b < a + +(+) infixl 6 :: !Int !Int -> Int +(+) a b = code inline { + addI +} + +inc :: !Int -> Int +inc a = a + 1 + +(-) infixl 6 :: !Int !Int -> Int +(-) a b = code inline { + subI +} + + +(==) infix 4 :: !Int !Int -> Bool +(==) a b = code inline { + eqI +} + +(<>) infix 4 :: !Int !Int -> Bool +(<>) a b = not (a == b) + +length :: [a] -> Int +length xs = len 0 xs +where + len :: Int [a] -> Int + len i [] = i + len i [_:xs] = len (i+1) xs + +hd :: [a] -> a +hd [x:xs] = x + +//import StdEnv BoardSize :== 8 // The size of the chessboard. |