Documentation for how operators and functions are.
This commit is contained in:
parent
bbfd1cdf43
commit
ff4a3662e7
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user