aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-10-10 06:53:24 +0100
committerAkshay <[email protected]>2020-10-10 06:53:24 +0100
commit883092e4ff4f8beb59e3d705ef247c235baa6bb7 (patch)
tree696a8a488a2995577ee2f5b60538f3839f6384f5 /src
parentf74d9c9bb3722fd20cea000b4f0c2a74be289a9c (diff)
complete definition of naryBool
i forgot to finish the function lol
Diffstat (limited to 'src')
-rw-r--r--src/Operators.hs6
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
25data LispNumber = I Integer 27data LispNumber = I Integer
@@ -66,7 +68,9 @@ unaryBool op args
66naryBool :: (Bool -> Bool -> Bool) -> [Expr] -> LispResult Expr 68naryBool :: (Bool -> Bool -> Bool) -> [Expr] -> LispResult Expr
67naryBool op args 69naryBool 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
71unwrapNum :: Expr -> LispResult LispNumber 75unwrapNum :: Expr -> LispResult LispNumber
72unwrapNum (IntLiteral n) = return $ I n 76unwrapNum (IntLiteral n) = return $ I n