diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Operators.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Operators.hs b/src/Operators.hs index e607250..45be7f3 100644 --- a/src/Operators.hs +++ b/src/Operators.hs | |||
@@ -20,6 +20,8 @@ primitives = | |||
20 | , ("=", comparator (==)) | 20 | , ("=", comparator (==)) |
21 | , ("!=", comparator (/=)) | 21 | , ("!=", comparator (/=)) |
22 | , ("not", unaryBool not) | 22 | , ("not", unaryBool not) |
23 | , ("or", naryBool (||)) | ||
24 | , ("and", naryBool (&&)) | ||
23 | ] | 25 | ] |
24 | 26 | ||
25 | data LispNumber = I Integer | 27 | data LispNumber = I Integer |
@@ -66,7 +68,9 @@ unaryBool op args | |||
66 | naryBool :: (Bool -> Bool -> Bool) -> [Expr] -> LispResult Expr | 68 | naryBool :: (Bool -> Bool -> Bool) -> [Expr] -> LispResult Expr |
67 | naryBool op args | 69 | naryBool op args |
68 | | length args < 2 = throwError $ ArgCount 2 args | 70 | | length args < 2 = throwError $ ArgCount 2 args |
69 | 71 | | otherwise = do | |
72 | as <- mapM unwrapBool args | ||
73 | return . BoolLiteral $ foldl1 op as | ||
70 | 74 | ||
71 | unwrapNum :: Expr -> LispResult LispNumber | 75 | unwrapNum :: Expr -> LispResult LispNumber |
72 | unwrapNum (IntLiteral n) = return $ I n | 76 | unwrapNum (IntLiteral n) = return $ I n |