RedLSystem rewrite strings



simple string rewrite class.


see also [RedLTurtle]


class methods:

*new(axiom, rules)

axiom is the starting string / seed

rules should be a dictionary in the form of (character: replacement string)


instance methods:

next

rewrite and go to next generation

reset

reset generation counter to zero and the production to the axiom

rules_(dict)

change the rules during the game - not recommended

dictionary in the form of (character: replacement string)

asString

convert nested production array into a single string


instance variables:

<>axiom

starting string

<rules

dictionary in the form of (character: replacement array of characters)

note the difference from the dictionary used for *new and rules_

<production

the current production as a nested array

<generation

counter



a= RedLSystem("F", ($F: "FO")) //a single rule - replace all F with FO

a.next

a.next

a.next


a= RedLSystem("F", ($F: "FO", $O: "O-F")) //multiple rules

a.next

a.next

a.next

a.next

a.generation

a.production //the nested array

a.rules //rules