Showing posts with label turtle. Show all posts
Showing posts with label turtle. Show all posts

Monday, October 28, 2013

toolz and curry

Lightning talk


Doing a quick lightning talk tonight for PYPTUG @WFU and it wont be about spanners and food as the title might imply, but about...

Functional programming


Yes, about functional programming in an imperative by design language (Python). And it's a lightning talk, so it'll be very superficial. But hopefully interesting nonetheless.

My first experience with pure functional programming was in the 80s with the Miranda programming language. If one counts impure functional such as LISP, scheme etc, then that would be Logo as my first.

Back to Python

One of the most appealing Pythonic technique I use on a regular basis, is functional. But more on that later. Here in this talk, I'll focus on a new module called Toolz (the result of a merge of functoolz and itertoolz - with a z, not the standard library functools and itertools).


François
@f_dion

Tuesday, September 4, 2012

Logo turtle graphics

I remember fondly going to the university with my dad, as a toddler first, and as a young boy later. Pretty quickly, I was able to gain access to the computer lab, where they had the Apple ][. Later they would get the ][+, //e etc.

Anyway, there, I could request a disk with a wonderful program called Logo turtle graphics. That was  my first real exposure to programming. You controlled a little triangle (the turtle), pen up / down to draw or move without drawing, back, forward, left, right (rotations), etc. There was even the possibility of loops, functions etc. You can learn more about Logo here Logo Foundation

The Raspberry Pi Raspbian operating system comes with Python, and as such, with Turtle.

In logo, I remember writing something like this:

repeat 10 [ circle 50 forward 60 right 36 ]

With python, the last 4 lines are equivalent:

$ python
>>> from turtle import *
>>> up()
>>> back(200)
>>> left(90)
>>> down()

>>>
>>> for x in range(10):
...    circle(50)
...    forward(60)
...    right(36)
...
>>>

The result?

As a side note, I took the snapshot from my OpenIndiana desktop. I accessed the Raspberry Pi using the command:

ssh -X pi@rasp01

This allows a tuneling of X Windows, so when I start python, import turtle and start drawing, it is drawing using tkinter using the OpenIndiana desktop X server to render the above window.


In conclusion

I do owe my > 30 years in programming and the mastering of various languages such as assembler, Basic, C, C++, Pascal, Java, Python, etc to my first exposure to programming at a young age. It is crucial that the youth of today similarly get exposed to more than how to use Office or Photoshop. They need to learn how to program and how to tinker. And the Raspberry Pi provides that ticket into that world.