G
Guest
I would like to have a list of lists N times deep, and my solution is (in
pseudocode):
def deep(x):
a=[x]
return a
mylist=[]
for N: mylist=deep(mylist)
Is there a more elegant way to do it?
The maine idea is: from a list having the numbre of steps along N
dimensions, generate a list with an item at each possible point.
Example 1: N=2 list=[2,3] result=[[1,2],[1,2],[1,2]]
Example 2: N=3 list=[3,1,2] result=[[[1,2,3]],[[1,2,3]]]
--
Ãngel Gutiérrez RodrÃguez - (e-mail address removed)
Instituto de Ciencia de los Materiales de Madrid - CSIC
SpLine - European Syncrothorn Radiation Facility - Grenoble - France
Postal adress: Departamento de QuÃmica FÃsica y AnalÃtica
Universidad de Oviedo - c/Julián ClaverÃa 8 33006 - Oviedo
Asturias - Spain
E-mail: (e-mail address removed) Telf.: +34-985103687
pseudocode):
def deep(x):
a=[x]
return a
mylist=[]
for N: mylist=deep(mylist)
Is there a more elegant way to do it?
The maine idea is: from a list having the numbre of steps along N
dimensions, generate a list with an item at each possible point.
Example 1: N=2 list=[2,3] result=[[1,2],[1,2],[1,2]]
Example 2: N=3 list=[3,1,2] result=[[[1,2,3]],[[1,2,3]]]
--
Ãngel Gutiérrez RodrÃguez - (e-mail address removed)
Instituto de Ciencia de los Materiales de Madrid - CSIC
SpLine - European Syncrothorn Radiation Facility - Grenoble - France
Postal adress: Departamento de QuÃmica FÃsica y AnalÃtica
Universidad de Oviedo - c/Julián ClaverÃa 8 33006 - Oviedo
Asturias - Spain
E-mail: (e-mail address removed) Telf.: +34-985103687