Re: How to do multi-dimensional arrays?

Tim Gilbert (gilbert@marin.cc.ca.us)
Thu, 26 Jan 1995 16:46:18 GMT

Gregor Schmid (gs@ivu-berlin.de) wrote:
: You mixed it up slightly. Try:

: >>> XXX = map( lambda x: map (lambda x: [x]*4, [0]*4), [0]*4)
: >>> XXX[1][2][3] = 123
: >>> XXX
: [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0,
: 0], [0, 0, 0 , 0], [0, 0, 0, 123], [0, 0, 0, 0]], [[0, 0, 0, 0], [0,
: 0, 0, 0], [0, 0, 0, 0], [0 , 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0, 0],
: [0, 0, 0, 0], [0, 0, 0, 0]]]

Say, would someone mind explaining to me what exactly that says? I know
what map(), [x]*4, etc do, but what is
lambda x: [x]*4, [0]*4
^^^^^ <-- this part doing?
And how does it all fit together?

--
Tim Gilbert <> gilbert@marin.cc.ca.us <> College of Marin, S.F. Bay Area
-- 
Tim Gilbert <> gilbert@marin.cc.ca.us <> College of Marin, S.F. Bay Area