The "joke" question Joel asked during podcast #58 made me all nostalgic for Logo, which was the second language I ever programmed in, after Basic, and which is why I never had any trouble with recursion in college.
Are there any implementations of Logo for Windows or Linux (the platforms I can use) or Mac (because I know I'm not alone in this world)? How can I get the Logo programming language for my computer?
Fire up a terminal on Mac or Linux, and type python
, then press Return or Enter. Then type from turtle import *
, then Return or Enter. Now type fd(100)
, then Return or Enter. Hooray! Logo with Python! =D (Windows users can install Python here)
For a complete list of commands, see the online documentation. Note that the documentation will tell you to type turtle.fd(100)
, rather than fd(100)
, because they chose to use import turtle
, rather than from turtle import *
. The star method is almost always bad, because it makes it possible to confuse your own functions with those in the module, but in this case it is good, because it lets us control the turtle with proper logo commands.
Create a file called shapes.py
, and save it somewhere sensible. Add the following code to shapes.py
:
from turtle import *
def square(size):
for i in range(4):
fd(100)
rt(90)
def fun(size):
for i in range (10):
square (size)
rt(36)
Now, whenever you want to do logo, navigate to wherever you saved shapes.py
before running python
. Then, after running python
, run from shapes import *
instead of from turtle import *
. This will import logo along with any custom functions you have defined in shapes.py
. So, whenever you make a cool function, just save it in shapes.py
for future use.
e.g. interactive session (after running python
from the relevant directory):
from shapes import *
square(100)
fun(50)