# Question:Nested lists whose number of nestings depend on a given number

## Question:Nested lists whose number of nestings depend on a given number

Maple
Hello everyone, I am trying to create a procedure to translate a matrix into a nested list. (in Maple 10) I actually want to transform the matrix A[i,j] whose indexes are in the interval i,j=1,2,... d^k in a list: L[n1,n2,...,n2k] whose indexes are in the intarval n1,n2,...n2k = 0,1,2...,d. For instance, a transformation of indexes could be: for i from 0 to d do for j from 0 to d do for k from 0 to d do for l from 0 to d do L[i, j, k, l] := DM*([1+(sum(d^(i-1)*n[i], i = 1 .. k)), 1+(sum(d^(i-1-k)*n[i], i = k .. 2*k))]) od: od: od: od: But I would actually like to indtroduce k and d as parameters of the procedure. My problem is then how to say: Here is k -> create a list with k indexes make k "do"-s to declare the list. Maybe the idea is to change from the root... Further down is the structure on which I tried to build the idea... without success... matrix2list:= proc(d,K,DM) local TEMPLIST: TEMPLIST:=M[cat( a, 1 .. 2*K )]: for i from 0 to d do for j from 0 to d do .... TEMPLIST[i,j,k,l, ....]:=DM [1+ sum(d^(i-1) n[i] ,i=1..K), 1+sum(d^(i-1-K) n[i] ,i=K..2K)] .... od: od: end: I think that M[cat( a, 1 .. 2*K )]: creates a list with 2K indexes... but I don't know how to declare it in a recursive way... Thanks everyone for your time, Al
﻿