Categories: Uncategorized

Improved Logo interpreter in Red

Using what I have learned in the last few days about ‘parse’ in Red, I have improved the Logo interpreter from the last post, so that it now supports procedures.

(It turns out that I had it all wrong about Red’s parse. It’s actually already full featured and it was a misunderstanding on my side that made me think it’s incomplete).

Anyway, it’s amazing how, with so little extra effort, it was possible to extend the Logo/Turtle program to do so much more, still all in under 100 lines of code! (Though when you think about it, you can paste you code in Notepad++ or Sublime Text and press Ctrl+J and then everything will be one one line of code! 🙂 ).

The only thing lacking, perhaps, is that I should use floats for the co-ordinates (done),  as there is some inaccuracy due to rounding, as the turtle just uses pair! co-ordinates corresponding to the pixels on the screen.

The last things I want to add are, as mentioned, changing the co-ordinates to use float! numbers (done) and adding an ‘undo’ command.

So the full list of commands is now:

You can find the code here:

Where is the turtle now?
Where is the turtle now?

Article info

Leave a Reply

Your email address will not be published. Required fields are marked *