Sketch · 2026-08-03
L-systems, from a string to a fern.
An L-system is a grammar. Start with a short axiom, apply a handful
of rewrite rules in parallel, and the string grows. Hand the string
to a turtle that walks on F, turns on + and
-, and remembers where it was on [ and
]. The same interpreter draws the Koch snowflake, the
dragon curve, a Hilbert space-filling walk and something that reads
as a plant.
- axiom
- F++F++F
- angle
- 60°
How the rewrite works
One step of an L-system replaces every symbol in the current string
with the right-hand side of its rule, all at once. Symbols without
a rule stay put. The Koch snowflake starts from
F++F++F and the single rule F → F-F++F-F.
After one step you have three of those six-character fragments
glued together. After four, the string is a few thousand symbols
long and the turtle draws the classic snowflake boundary.
Why the turtle is the trick
The grammar knows nothing about geometry. The geometry lives in the
interpreter: how far each forward step goes, what angle each turn
takes, and whether [ and ] are wired up
to save and restore the turtle's state. Add those brackets and the
string can describe a branching structure that stops and comes
back. That is why the same machinery draws a curve one moment and
a plant the next.
Ferns without noise
The fern preset uses a rule Lindenmayer's students refined into a small catalogue of plant-like grammars in the 1980s. It is deterministic. There is no randomness. Every leaflet is a scaled copy of the same subtree, and the shape you see is what happens when a purely context-free rewrite runs for five or six steps and gets interpreted by a bracketed turtle. Real ferns do this too, more or less.
Sources
- Lindenmayer, A. (1968). Mathematical models for cellular interactions in development. Journal of Theoretical Biology, 18(3), 280–299. The original paper.
- Prusinkiewicz, P. & Lindenmayer, A. (1990). The Algorithmic Beauty of Plants. Springer. The reference for plant-shaped L-systems; the fern and plant rules here are lifted from chapter one.
- Prusinkiewicz, P. (1986). Graphical applications of L-systems. Proceedings of Graphics Interface, 247–253. Where the bracketed turtle-graphics interpreter is spelled out.