Sierpinski Carpets in Common Lisp

Return to Projects page
What it is:

Start with any rectangle. Divide it into a 3 x 3 grid of equal-sized rectangles. Remove the middle one. Repeat this process on each of the remaining eight rectangles, ad infinitum.

Or take the additive approach: Start with a single 1-unit tile. Replace it with a square of eight 1-unit tiles surrounding an empty square. Repeat on each of the eight new tiles, and so on...



Why?

Implementing the above looked like an interesting way to learn some Common Lisp.



Common Lisp code to make Sierpinski Carpets:

sierpinski.lisp

Sample SVG output


An output sample converted to PNG

Return to Projects page