Skip to content

Instantly share code, notes, and snippets.

@rm-hull
Last active December 15, 2015 15:59
Show Gist options
  • Save rm-hull/5285431 to your computer and use it in GitHub Desktop.
Save rm-hull/5285431 to your computer and use it in GitHub Desktop.
The Heighway dragon (also known as the Harter–Heighway dragon or the Jurassic Park dragon) was first investigated by NASA physicists John Heighway, Bruce Banks, and William Harter. It was described by Martin Gardner in his Scientific American column Mathematical Games in 1967. It is a self-similar fractal curve, which can be approximated by recu…
(ns lindenmayer-systems.demo
(:use [turtle.core :only [draw!]]
[turtle.renderer.canvas :only [->canvas]]
[enchilada :only [ctx canvas]]
[jayq.core :only [show]]))
(def dragon-seq
"Unfolding the dragon"
(letfn [(seq0 [x y]
(lazy-seq (cons (flatten x) (seq0 [x :right 90 y :fwd 20] [:fwd 20 x :left 90 y]))))]
(seq0 [] [])))
(show canvas)
(draw! (->canvas ctx) (nth dragon-seq 13) [800 600])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment