Functor Lilis.Make

module Make (Lstream : S) : sig .. end
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.

Parameters:
Lstream : S

val eval_lsys : int ->
('a * string Calc.t list) Lilis.lsystem -> ('a * float array) Lstream.t
Evaluate a L-system at the n-th generation.

Compression functions



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 
type 'a crules 
val compress_rules : Lilis.SymbEnv.t ->
(string * string Calc.t list) Lilis.rule list -> int crules
val compress_post_rules : Lilis.SymbEnv.t ->
('a * string Calc.t list) Lilis.rule list -> 'a crules
val compress_lslist : Lilis.SymbEnv.t -> string Lilis.stream -> (int * float array) Lstream.stored
val compress_lsys : ('a * string Calc.t list) Lilis.lsystem ->
Lilis.SymbEnv.t * (int * float array) Lstream.stored *
int crules * 'a crules
val compress_lstream : Lilis.SymbEnv.t -> string lstream -> int lstream
val uncompress_lstream : Lilis.SymbEnv.t -> int lstream -> string lstream
val map_crules : ('a -> 'b) -> 'a crules -> 'b crules

Engine


val apply : ?n:int ->
int crules -> int lstream -> int lstream
apply rules lstream will apply rules once to lstream. The optional argument n can be used to apply more than once.
val apply_complete : 'a crules -> int lstream -> 'a lstream
As apply but with a complete mapping. Symbols without rules are suppressed.
val eval_lsys_uncompress : int ->
('a * string Calc.t list) Lilis.lsystem -> (string * float array) Lstream.t
Like eval_lsys , but will ignore post rules and uncompress the stream instead.

Not really safe


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.
val eval_iter_lsys : int ->
('a * string Calc.t list) Lilis.lsystem ->
store:bool ->
('a -> (float array -> float) array -> float array -> unit) -> unit -> unit
val eval_fold_lsys : int ->
('a * string Calc.t list) Lilis.lsystem ->
store:bool ->
('a -> (float array -> float) array -> 'b -> float array -> 'b) -> 'b -> 'b