(* Tapis de Sierpinski *)

type quad = White | Black | Node of quad * quad * quad * quad

let node = function
  | White, White, White, White -> White
  | Black, Black, Black, Black -> Black
  | q1, q2, q3, q4 -> Node (q1, q2, q3, q4)

let rec fractal n =
  if n = 0 then
    Black
  else
    let f = fractal (n - 1) in
    node (node (f, f, White, f),
          node (f, f, f, White),
          node (White, f, f, f),
          node (f, White, f, f))

This document was generated using caml2html