I'm going to teach using the well known drawing turtle, with one developed by me to fit my students, so in case it can also be modified. It features drawing movement, non-drawing movement and pen color change.
The main goal is letting them have a strong visual feedback and appreciate the decomposition of complex movements. I have some examples that use functions to represent "subtasks" and repetitions to generate nice drawings.
I'm anyway a bit stuck here, say at the visual artist stage, I'd like to show them the use of a while kind of loop instead of a statically limited for, but I don't have good ideas besides using the "while" condition to stop some recursion based for example on the next step length (imagine drawing a spiral with increasing step length and wanting to halt at some point).
It seems to me that my main difficulty has to do with the absence of interesting states from the examples, the only one that comes to mind being precisely the use of a step length.
The system also features 2 things.
- A stack for saving turtle configurations, you can push the current position and pop it later... Fractals? It seems that those coming to my mind are more easily accessed by recursion than by a stack.
- The ability to save a user state and access it, it can be used for example to keep a counter that changes when desired and is then used to choose a pen color from a palette. It can contain arbitrary data and the motivation was to use it as an aid for learning about mutating variables.
I anyway seem to not have good ideas for examples to link these tools to actual interesting problems. Any suggestions?
What can be easily computed by the turtle?
(define (while c f) (begin (f) (when (c) (while c f))))
. $\endgroup$