Documentation for how operators and functions are.

This commit is contained in:
JonathanILevi 2020-02-21 14:04:36 -06:00 committed by Mahdi Dibaiee
parent bbfd1cdf43
commit ff4a3662e7

View File

@ -9,15 +9,26 @@ module Numeric.MathExpr
import Data.Maybe (isJust, fromJust) import Data.Maybe (isJust, fromJust)
import Data.List (find) import Data.List (find)
-- | Operators are in the form (character, precedence, function)
-- Example: ('+', 0, (+)), ('', 1, ())
-- (higher the precedence, the sooner the operator operates)
--
-- Functions are in the form (name, function)
-- Example: ("ln", log)
data Settings = Settings { operators :: [(Char, Int, Double -> Double -> Double)] data Settings = Settings { operators :: [(Char, Int, Double -> Double -> Double)]
, functions :: [(String, Double -> Double)] , functions :: [(String, Double -> Double)]
} }
-- | Operators are in the form (character, precedence, function)
-- Example: ('+', 0, (+)), ('', 1, ())
-- (higher the precedence, the sooner the operator operates)
defaultOperators = [ defaultOperators = [
('+', 0, (+)), ('-', 0, (-)), ('+', 0, (+)), ('-', 0, (-)),
('*', 1, (*)), ('/', 1, (/)), ('*', 1, (*)), ('/', 1, (/)),
('^', 2, (**)) ('^', 2, (**))
] ]
-- | Functions are in the form (name, function)
-- Example: ("ln", log)
defaultFunctions = [("ln", log), ("sin", sin), ("cos", cos)] defaultFunctions = [("ln", log), ("sin", sin), ("cos", cos)]
instance Default Settings where instance Default Settings where