| The 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.
|