the production rules. Each character of the input string is checked against the rule list to determine which character or string to replace it with in the output string. In this example, a '1' in the input string becomes '11' in the output string, while '[' remains the same. Applying this to the axiom of '0', we get: We can see that this string quickly grows in size and complexity. This string can be drawn as an image by using turtle graphics, where each symbol is assigned a graphical operation for the turtle to perform. For example, in the sample above, the turtle may be given the following instructions: 0: draw a line segment ending in a leaf 1: draw a line segment [: push position and angle, turn left 45 degrees ]: pop position and angle, turn right 45 degrees The push and pop refer to a LIFO stack (more technical grammar would have separate symbols for "push position" and "turn left"). When the turtle interpretation encounters a '[', the current position and angle are saved, and are then restored when the interpretation encounters a ']'. If multiple values have been "pushed," then a "pop" restores the most recently saved values. Applying the graphical rules listed above to the earlier recursion, we get: Example 3: Cantor set variables : A B constants : none start : A {starting character string} rules : (A → ABA), (B → BBB) Let A mean "draw forward" and B mean "move forward". This produces the famous Cantor's fractal set on a real straight line R. Example 4: Koch curve A variant of the Koch curve which uses only right angles. variables : F constants : + − start : F rules : (F → F+F−F−F+F) Here, F means "draw forward", + means "turn left 90°", and − means "turn right 90°" (see turtle graphics). n = 0: F n = 1: F+F−F−F+F n = 2: F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F n = 3: F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F+ F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F− F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F− F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F+ F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F Example 5: Sierpinski triangle The Sierpinski triangle drawn using an L-system. variables : F G constants : + − start : F−G−G rules : (F → F−G+F+G−F), (G → GG) angle : 120° Here, F means "draw forward", G means "draw forward", + means "turn left by angle", and − means "turn right by angle". It is also possible to approximate the Sierpinski triangle using a Sierpiński arrowhead curve