summaryrefslogtreecommitdiff
path: root/squeen.icl
diff options
context:
space:
mode:
Diffstat (limited to 'squeen.icl')
-rw-r--r--squeen.icl79
1 files changed, 78 insertions, 1 deletions
diff --git a/squeen.icl b/squeen.icl
index cd67c16..205bffd 100644
--- a/squeen.icl
+++ b/squeen.icl
@@ -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.