From: olipt at mayo.edu (Travis Oliphant)
Date: Thu, 13 May 1999 22:20:29 -0500
Subject: python hack of the day -- "listable" functions
In-Reply-To: <373e4c42.16914501@news.omnilink.de>
References: <jlaev9ooh1.fsf@arathorn.bbb.caltech.edu> <373c22bf.6287591@news.omnilink.de> <slrn7jmcn3.nmo.wtanksle@dolphin.openprojects.net> <373e4c42.16914501@news.omnilink.de>
Message-ID: <Pine.LNX.4.10.9905132213040.5719-100000@us2.mayo.edu>
X-UID: 1949                                                 

> >
> >This isn't true -- there are languages which do exactly this.  I think
> >Icon is one, and I know APL, J, and K are

Add the Numeric extensions (umath) in particular and you get this behavior
now.
> 1) we had an aditional builtin type 'dollar', so we could write
> >>> x = $[1, 2, 3, 4]
> >>> type(x)
> <type 'dollar'>
> >>> x
> $[1, 2, 3, 4]
> >>> 2*x+1
> $[3, 5, 7, 9]
> >>> undollar (x)
> [1, 2, 3, 4]
> 

Go get the Numeric extensions,

>>> from Numeric import *
>>> x = array([1,2,3,4])
>>> 2*x + 1
>>> array([3,5,7,9])
>>> x.tolist()
>>> [1, 2, 3, 4]

You can also do some clever things with multidimensional arrays.  It's
pretty much equivalent to what's available in J (as far as I know).

But, there are no $ signs....

Travis






