Library
Module
Module type
Parameter
Class
Class type
A functor to build your own little L-system engine given a stream-like data structure. Can be lazy or not, functional or not.
The important operations from the performance point of view are expand
and map
. Concatenation (as used in expand
) must absolutely be in O(1) amortized time. Laziness is better for memory occupation but is not necessary.
Evaluate a L-system at the n-th generation.
A L-system is first compressed before being iterated on. This compression allows far better performances.
One of the steps of compression is to transform string symbols into int. To be allowed to transform back and forth a lstream, the compress_lstream
function provides an environment from string symbols to int. This environment can be used by compress_lstream
and uncompress_lstream
for O(n) compression/uncompression. The laziness of Lstream
is respected.
type 'a lstream = ('a * float array) Lstream.t
val compress_lslist :
SymbEnv.t ->
string stream ->
(int * float array) Lstream.stored
apply rules lstream
will apply rules once to lstream
. The optional argument n
can be used to apply more than once.
As apply
but with a complete mapping. Symbols without rules are suppressed.
val eval_lsys_uncompress :
int ->
('a * string Calc.t list) lsystem ->
(string * float array) Lstream.t
Like eval_lsys
, but will ignore post rules and uncompress the stream instead.
val iter_complete :
((float array -> float) array -> float array -> unit) crules ->
int lstream ->
unit
Take a rule composed of unit functions and apply it to the stream.