diff options
author | Akshay <[email protected]> | 2020-10-10 06:53:24 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-10-10 06:53:24 +0100 |
commit | 883092e4ff4f8beb59e3d705ef247c235baa6bb7 (patch) | |
tree | 696a8a488a2995577ee2f5b60538f3839f6384f5 | |
parent | f74d9c9bb3722fd20cea000b4f0c2a74be289a9c (diff) |
complete definition of naryBool
i forgot to finish the function lol
-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 |