Enter derivation rules

A derivation rule maps single characters to output strings

The starting string is called w. You must have exactly one derivation rule for w



This is very similar to yesterday's L-System Fractal Generator except this version introduces bracket operators to save and restore state. It also uses : for defining derivation rules rather than -> because it is easier to type.

Samples

Example

w: F
F: F+F

On the first iteration, we look up the rule for w. The output string is F

On the second iteration, we replace every F in the input string with F+F. The output string is F+F

On the third iteration, we replace every F in the input string with F+F. The output string is F+F+F+F

And so on...

After running n iterations, the output string is used as drawing instructions. The pen starts at the origin aiming north.

Further reading: Chapter 1.6 of The Algorithmic Beauty of Plants