On Sunday, I thought I’d try and show my son the fun side of programming and Logo seemed a good place to start. Using a Logo Interpreter written in JavaScript, in seconds we were drawing pentagons.
to pentagon repeat 5 [ fd 100 rt 72 ] end
That jogged my memory to a cool sample Logo Interpreter written by Adam Granicz in less than 400 lines, posted on HubFS back in 2006. The code didn’t run straight away due to some subtle changes in the language, but after some worthwhile coercion I was able to resurrect the code, which I have attached.
Try executing:
canvas 300 300
to pentagon :x repeat 5 [ fd :x rt 72 ]
pentagon 100
and:
canvas 400 500
spiral :x repeat :x [fd 4 lt * repcount 1.1]
spiral 10000
Logo.fsx (19.71 kb)