Skip to content

rachbowyer/henderson

Repository files navigation

Henderson

Picture of William Barton Rogers transformed by the Square Limit transformation

Henderson is a partial implementation in Clojure of the Henderson Picture Language (HPL) described in Structure and Interpretation of Computer Programs by Harold Abelson and Gerald Sussman (aka SICP).

HPL was invented by Professor Peter Henderson and first described in his 1982 paper (Henderson, P. (1982) Functional Geometry. Proc. ACM Symp. on Lisp and Functional Programming. pp. 179-187). An updated version of the paper is available here. SICP uses HPL to illustrate abstraction, high order functions, combinators and composition.

Around 6 years ago, I was working through SICP in Clojure and arrive at Chapter 2.2.4. I was unable to render my painters so set about writing an implementation in Clojure. I always planned to pull the code out into a standalone library, but never found the time until now!

Installation

Henderson is available from Clojars.

Clojars Project

Usage

To make the Henderson functions available type:

(require '[henderson.core :as hc])
(require '[henderson.examples :as he])

There are predefined painters wave, wave2, wave4 and rogers as described in SICP. The function show-picture will render a painter. Examples (from page 133 SICP 2nd Edition)

 (hc/show-picture (hc/right-split he/wave 4) 400 400)
 (hc/show-picture (hc/corner-split he/rogers 4) 400 400)

Note that the origin is at the top left, positive x goes right and positive y goes down in accordance with Java2d and most UI systems.

For more information see the docs in /doc and of course SICP!

License for Henderson

Distributed under the Creative Commons Attribution-ShareAlike 4.0 International licence ("CC BY-SA 4.0")

Releases

No releases published

Packages

No packages published