SOURCE APPENDIX
The Small Library Behind the Pictures
The chapter files should say what the fractal does. Repeated Matplotlib machinery belongs somewhere else.
The rule
Mathematics stays local; presentation is shared. The Python module fractalfair_helpers.py owns SVG export, clean axes, fitting, gradient paths, point clouds, scalar/RGB images, triangles and Cantor staircases. It deliberately does not contain a Koch, Mandelbrot, fern or Hilbert algorithm.
Why the chapter code gets better
def draw(depth=7):
return staircase_figure(cantor(depth), depth)The interesting name is now cantor, not plt.subplots. This is the same reason the book shows K&R-style pseudocode before Python: first see the idea, then see the executable syntax.
The Haskell mirror
FractalFairHelpers.hs performs the same small separation for the diagrams versions: common gradients and path rendering are shared, while recursion, grammars, affine maps and complex iterations remain in the individual modules.
main = mainWith
(gradientPath oceanGradient 1.6 (snowflake 4))Three views of one algorithm
pseudocode → Python → Haskell
Pseudocode exposes control flow. Python is directly runnable. Haskell often exposes the algebraic structure. The goal is not three programs; it is one idea seen three ways.