Hello,
Back in 2010, during a functional programming course, I wrote a small OCaml program that draws fractals with iterated function systems (IFS), using the graphics library and the chaos game. It is one of my oldest repositories still alive, and it had barely changed since:
Each fractal is just a record: a list of affine transforms with cumulative weights, plus a viewport. The chaos game does the rest. The Barnsley fern is twenty-four coefficients.
Last weekend I dusted it off, and as an experiment I asked Claude Fable 5 to invent new IFS fractals rather than fix or refactor anything. I wrote up the full story on my blog, but the parts that might interest people here:
- The repo went from eleven predefined fractals to sixteen. The nicest newcomer in my opinion is lace, Queen Anne’s lace (wild carrot): an umbel of umbels, where five transforms place shrunken rotated copies of the whole plant on the rim of a dome and a sixth squashes everything into the stem. Thirty-six numbers total:
let lace =
{ po = {x= -0.90 ; y= -0.55};
sz = {x= 1.80 ; y= 2.00};
lt = [{pb= 0.18; kf= [| 0.2649; 0.1408; -0.7048; -0.1408; 0.2649; 0.38|]};
{pb= 0.36; kf= [| 0.3493; 0.0871; -0.4302; -0.0871; 0.3493; 0.5013|]};
{pb= 0.54; kf= [| 0.38; 0.00; 0.00; 0.00; 0.38; 0.55|]};
{pb= 0.72; kf= [| 0.3493; -0.0871; 0.4302; 0.0871; 0.3493; 0.5013|]};
{pb= 0.90; kf= [| 0.2649; -0.1408; 0.7048; 0.1408; 0.2649; 0.38|]};
{pb= 1.00; kf= [| 0.02; 0.00; 0.00; 0.00; 0.55; 0.00|]}]};;
- A sunflower built on phyllotaxis with only two transforms: one rotates by the golden angle (137.508°) while contracting toward the center, the other plants a bud at the rim. Because the golden angle is the “most irrational” angle, the buds fill the disk evenly, just like real seed heads.
- A fun negative result: I asked for the vegvísir, the Icelandic stave. Strictly speaking an IFS cannot draw it, since the attractor is a single self-similar set while the real symbol has a different rune on each of its eight arms. The workaround was a non-contracting map, a pure 45° rotation at scale 1.0 that draws nothing itself and only distributes points across the eight arms, so the other transforms only need to describe one arm. I had never thought of using a measure-preserving map as a “symmetry map” like that.
- The takeaway I keep coming back to: plants make good IFS subjects because they grow by iterating simple local rules, so their shape literally is an attractor. Designed symbols resist because nobody grew them.
The write-up with all the images is here:
If you want to play with it: opam install graphics ocamlfind, then in the toplevel #use “ifs_fractals.ml”;; and draw lace 300000;;.
I am curious whether others have used non-contracting symmetry maps in IFS before, or have favorite attractors worth adding. And if anyone remembers writing this kind of toy in an OCaml course, I would love to hear about it. Pull-requests are of course welcome!

