
your thoughts most welcome - Jason
I agree that prefix notation (+ 1 1) vs. infix notation (1 + 1) is something of a curve ball for most of us. That's why I'd do some work to introduce it earlier, perhaps by booting DrScheme on a classroom projector. "Look folks," I'd say "we all get used to a = 1 + 1 from our text books, but you should realize that's cultural, and a serious alternative, actually used in some computer languages, would go like this (define a (+ 1 1)). Note that 'define', which plays the role of '=', is likewise a prefix -- very consistent." This comes under the heading of "ET Math" or "Math from Mars" in my book -- a sort of genre I work with. The point is to give insights into math by showing "what could be different, and still be of utility to an intelligent life form".[1] I do something similar with coordinate systems, showing an apparatus that uses 4-tuples of non-negatives to map ordinary volume (similar to XYZ in other words) -- a gizmo I call "the quadrays coordinate system" and have researched with colleagues.[2] Another game is to show how triangles and tetrahedra make fine models of 2nd and 3rd powering respectively, so we could be saying "3 tetrahedroned = 27" instead of "3 cubed = 27".[3] Again, we're brushing up against a whole other paradigm, an "ET Math" if you will. In other words, I think this prefix vs. infix discussion presents a great opportunity to open a door, expand the mind. That being said, we don't necessarily have to go through the door and spend the whole semester there. For kids encountering all this stuff for almost the first time, it's all pretty alien, and too many alternatives all at once can be too disorienting -- so I think we should walk a fine line. Open a lot of doors, but don't try to go through them all. Leave them for later -- you can come back to this stuff. I'm thinking Python might be used to open a door to Scheme. Instead of the usual thing, of putting two languages side-by-side and showing how different they are, we can modify our style of coding in Python to make it appear more Scheme-like. We can write recursively, for example, and do some functional programming kind of things. For example, you can define car and cdr of LISP fame:
def car(mylist): if len(mylist)==0: return [] else: return mylist[0]
def cdr(mylist): if len(mylist)==0: return [] else: return mylist[1:]
Usage:
car([1,2,3,4,5]) 1 cdr([1,2,3,4,5]) [2,3,4,5]
In Scheme:
(define mylist '(1 2 3 4 5)) (car mylist) 1 (cdr mylist) (2 3 4 5)
Then we can do something recursive like this:
from operator import *
def Reduce(operator,mylist): if len(mylist)==1: return car(mylist) else: return apply(operator, (car(mylist), Reduce(operator, cdr(mylist))) )
Reduce(add,[1,2,3,4,5]) # = (+ 1 (+ 2 (+ 3 (+ 4 5)))) 15 Reduce(mul,[1,2,3,4,5]) + = (* 1 (* 2 (* 3 (* 4 5)))) 120
Note that I've named this Reduce, not reduce, which is a built-in, and gives the same results:
reduce(add,[1,2,3,4,5]) 15 reduce(mul,[1,2,3,4,5]) 120
Although Scheme purists might have little patience for such stuff, I think this helps communicate some of the flavor of Scheme to those more familiar with Python. In sum, even if going with Python as a first language, I'd open a door to Scheme via introducing prefix notation, and would lay some groundwork in Python (as per the above example) for latter tackling Scheme and similar languages. Kirby [1] more re "ET Math": http://www.teleport.com/~pdx4d/amtepost2.html [2] http://www.teleport.com/~pdx4d/quadintro.html (links to Python implementation in 'For further reading') [3] http://www.rwgrayprojects.com/synergetics/s09/figs/f9001.html