(associative & ops)
Takes a sequence ops
of operator symbols like '+
, '*
and returns a rule
that collapses nested applications of each operation into a single list. (The
associative property lets us strip parentheses.)
(let [rule (associative '+ '*)
f (rule-simplifier rule)]
(f '(+ x (+ y (+ z a) (* b (* c d))
(+ cake face)))))
;;=> (+ x y z a (* b c d) cake face)
Takes a sequence `ops` of operator symbols like `'+`, `'*` and returns a rule that collapses nested applications of each operation into a single list. (The associative property lets us strip parentheses.) ```clojure (let [rule (associative '+ '*) f (rule-simplifier rule)] (f '(+ x (+ y (+ z a) (* b (* c d)) (+ cake face))))) ;;=> (+ x y z a (* b c d) cake face) ```
(constant-elimination op constant)
Takes an operation op
and an identity element constant
and returns a rule
that eliminates instances of constant
inside binary forms like (<op> l r)
.
Takes an operation `op` and an identity element `constant` and returns a rule that eliminates instances of `constant` inside binary forms like `(<op> l r)`.
Set of rules that collect adjacent products, exponents and nested exponents into exponent terms.
Set of rules that collect adjacent products, exponents and nested exponents into exponent terms.
(unary-elimination & ops)
Takes a sequence ops
of operator symbols like '+
, '*
and returns a rule
that strips these operations off of unary applications.
(let [rule (unary-elimination '+ '*)
f (rule-simplifier rule)]
(f '(+ x y (* z) (+ a))))
;;=> (+ x y z a)
Takes a sequence `ops` of operator symbols like `'+`, `'*` and returns a rule that strips these operations off of unary applications. ```clojure (let [rule (unary-elimination '+ '*) f (rule-simplifier rule)] (f '(+ x y (* z) (+ a)))) ;;=> (+ x y z a) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close