Skip to content

Instantly share code, notes, and snippets.

@stedolan
Created September 22, 2020 11:49
Show Gist options
  • Save stedolan/414039f3b6d61bfe5d5184b9f8a616e2 to your computer and use it in GitHub Desktop.
Save stedolan/414039f3b6d61bfe5d5184b9f8a616e2 to your computer and use it in GitHub Desktop.
type tree =
| Leaf of { mutable x : int }
| Br2 of tree * tree
| Br5 of tree * tree * tree * tree * tree
let rec mk = function
| n when n <= 0 -> Leaf { x = 0 }
| n when n mod 3 = 0 -> Br2 (mk (n - 1), mk (n - 1))
| n -> Br5 (mk (n-1), mk (n-2), mk (n-3), mk (n-4), mk (n-5))
let rec go () =
let a = Array.make 10 (Leaf { x = 0}) in
for i = 1 to 1000 do
a.(i mod Array.length a) <- mk 15
done
let () = go ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment