Array of 2^n
agold at bga.com
Sun Oct 21 05:17:25 CEST 2001
> Okay, python newbie here. I'm liking what I see, but it seems like there
> are holes in the features of python's objects. I remember programming in
> squeak (an extension of smalltalk), and you could do complex operations on
> lists, and it would apply the result to each item. I want to make a n-item
> list such that mylist[i] = 2**i. How can I generate such a list in Python?
As an example, suppose you wanted the first 10 powers of 2 (i.e. 2**0 to
map(lambda x: 2**x, range(0,10))
would do it. Ayn b'ah'yah.
Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info)
mailto:agold at bga.com or mailto:agold at cs.utexas.edu
"Verbing weirds language." -- Calvin
More information about the Python-list