 Iterate - Maple Help

Fractals[LSystem]

 Iterate
 Formal Language Iterator Calling Sequence Iterate(state, rules, iterations) Parameters

 state - string or Vector(integer) ; the current state of the LSystem rules - list(character=string) or table(integer=list(integer)) ; the iteration rules for the given state iterations - nonnegint ; (optional) number of iterations to be applied Options

 • returnVector : keyword option of the form returnVector=value where value is true or false. If returnVector=true then a Vector corresponding to the ascii representation of the new state will be returned, otherwise the new state will be returned in the same format as state. Description

 • The Iterate command takes in a state and applies an iteration rule to each element, which is typically used to form an LSystem state.
 • The state parameter is a sequence of characters. It can be input as a string, or as Vector of integers in the range [1,255], whose values correspond to the ascii values of the characters of the sequence.
 • The iteration rules are defined by the rules parameter. An iteration will replace each element in the state with its corresponding iteration rule. If rules is input as list(character=string), the right-hand side of each equation in the list will replace the corresponding left hand side character at each occurrence of the character in the state. An element with no iteration rule defined will map to itself. The rules parameter may also be input as table(integer=list(integer)) (that is, a table where integers in the range [1,255] index to lists of integers in the range [1,255]). Each integer corresponds to an ASCII value and each occurrence of an ASCII value in state will get replaced by the corresponding list of integers.
 • The iterations parameter defines the number of iterations that will be performed. This value is 1 by default.
 • Iterate returns the iterated state in the same format as the input of state, unless otherwise specified by the returnVector option.
 • The Iterate command can be used with LSystem[LSystemPlot] to create LSystem plots. Examples

 > $\mathrm{with}\left(\mathrm{Fractals}:-\mathrm{LSystem}\right):$
 > $\mathrm{state},\mathrm{rules}≔"F",\left["F"="FF-\left[-F+F+F\right]+\left[+F-F-F\right]"\right]$
 ${\mathrm{state}}{,}{\mathrm{rules}}{≔}{"F"}{,}\left[{"F"}{=}{"FF-\left[-F+F+F\right]+\left[+F-F-F\right]"}\right]$ (1)
 > $\mathrm{newstate}≔\mathrm{Iterate}\left(\mathrm{state},\mathrm{rules}\right)$
 ${\mathrm{newstate}}{≔}{"FF-\left[-F+F+F\right]+\left[+F-F-F\right]"}$ (2)
 > $\mathrm{state},\mathrm{rules}≔"A",\left["A"="ABBA","B"="BAAB"\right]$
 ${\mathrm{state}}{,}{\mathrm{rules}}{≔}{"A"}{,}\left[{"A"}{=}{"ABBA"}{,}{"B"}{=}{"BAAB"}\right]$ (3)
 > $\mathrm{newstate}≔\mathrm{Iterate}\left(\mathrm{state},\mathrm{rules},3\right)$
 ${\mathrm{newstate}}{≔}{"ABBABAABBAABABBABAABABBAABBABAABBAABABBAABBABAABABBABAABBAABABBA"}$ (4)
 > $\mathrm{state},\mathrm{rules}≔"ABC",\left["A"="B","B"="C","C"="A"\right]$
 ${\mathrm{state}}{,}{\mathrm{rules}}{≔}{"ABC"}{,}\left[{"A"}{=}{"B"}{,}{"B"}{=}{"C"}{,}{"C"}{=}{"A"}\right]$ (5)
 > $\mathrm{newstate}≔\mathrm{Iterate}\left(\mathrm{state},\mathrm{rules},3\right)$
 ${\mathrm{newstate}}{≔}{"ABC"}$ (6) Compatibility

 • The Fractals:-LSystem:-Iterate command was introduced in Maple 2015.