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 - [EMAIL PROTECTED]
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: [EMAIL PROTECTED] Telf.: +34-985103687
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to