module LisOptim:sig
..end
val constant_folding : ('a * string Calc.t list) Lilis.lsystem ->
('a * string Calc.t list) Lilis.lsystem
For exemple, let's consider the L-system featuring the following rules:
rule A(x) = X Y(3*x, 2*x) A(x-1) F(2) Z post rule X = Turn(60) post rule Y(x,y) = Forward (x+y) post rule F(l) = Forward(l)
We will create two new rules for X+Y
and X+Z
. Z
doesn't have any post rules so it doesn't contribute to the new post rule. Since only x
appears in X Y(3*x, 2*x)
, the new post rule will only have one argument. Here is the resulting L-system:
rule A(x) = X+Y(x) A(x-1) F+Z post rule X = Turn(60) post rule Y(x,y) = Forward (x+y) post rule F(l) = Forward(l) post rule X+Y(x) = Turn(60) Forward (3*x+2*x) post rule F+Z = Forward(2)
val compress_calcs : ?env:Calc.Env.t ->
('a * string Calc.t list) Lilis.lsystem ->
('a * string Calc.t list) Lilis.lsystem
Calc.compress
to every arithmetic expressions.