Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (16 sloc) 553 Bytes
module Numerics
where
import Types
import Control.Monad.Error
import Helpers
math :: (Integer -> Integer -> Integer) -> [LispVal] -> ThrowsError LispVal
math op singleVal@[_] = throwError $ NumArgs 2 singleVal
math op params = mapM unpacknum params >>= return . Number . foldl1 op
numerics :: [(String, [LispVal] -> ThrowsError LispVal)]
numerics = [("+", math (+)),
("-", math (-)),
("*", math (*)),
("/", math div),
("mod", math mod),
("quot", math quot),
("rem", math rem)]
Jump to Line
Something went wrong with that request. Please try again.