Lecture overview -- Keyboard shortcut: 'u'  Previous page: Building Hilbert Curves of order 4 -- Keyboard shortcut: 'p'  Next page: Continuations [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 3 - Page 31 : 42
Functional Programming in Scheme
Name binding, Recursion, Iteration, and Continuations
A program making Hilbert Curves

Given our understanding of Hilbert Curves obtained from the previous pages, we will now study a computer program that generates Hilbert Curves of order n, where n is any non-negative number.

We will here discuss a concrete program which draws Hilbert Curves of order n

y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/graphics/svg-sources/hilbert-clean.lamlThe function hilbert programmed in Scheme as a functional program.

The function returns the path of the Hilbert Curver of order n. The parameter turn determines the rotation of the curve. In the top level call we ask for an upward Hilbert Curve: As an example, (hilbert 3 'up) produces an upward Hilbert Curve of order 3. The red fragments are responsible for all line drawing. The blue fragments represent all the recursive calls of the hilbert function. Finally, the green fragment represent the level 0 'basis' case. The level 0 case returns the empty Hilbert Curve, which is literally empty (no drawing at all - no contribution to the resulting path). What does it mean that the the program is a functional program? Well, it basically means that hilbert returns a value which can be rendered somehow by another function or procedure. The value returned is a path, composed by concat-path. The hilbert function does not carry out any action itself.

y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/graphics/svg-sources/hilbert-clean.lamlThe complete Hilbert programs including SVG details.


y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/graphics/svg-sources/svg-paths.scmA simple Scheme path library developed for SVG.