Copyright | Copyright 2024 Yoo Chung |
---|---|
License | Apache-2.0 |
Maintainer | dev@chungyc.org |
Safe Haskell | None |
Language | GHC2021 |
Synopsis
- order :: Text -> Expression -> Expression
Documentation
:: Text | Symbol representing the variable. |
-> Expression | Expression to be ordered. |
-> Expression | Expression with terms re-ordered. |
Order terms in an mathematical expression.
Terms will be ordered according to a deterministic set of rules. The re-ordering aims to make it easier to identify common factors and terms. Terms with higher integral powers of the variable are sorted later. Addition and multiplication will be re-arranged to associate to the left.
>>>
toHaskell $ order "x" $ "x" + 1
"1 + x">>>
toHaskell $ order "x" $ 2 + 3 * "x"**2 + "x"
"2 + x + 3 * x ** 2"