As i needed arrays (for constructing functions for creating large matrices), i 
didnt find any suiting objects in GAPs docu, but perhaps its my fault and i 
only didnt find it.

List processing only allows for access to already bound elements and only one 
indexlevel for enlarging lists. So you cannot freely index list elements 
especially
for programming purposes creating and processing lists of arbitrary nesting 
levels.

So I wrote a function for the definition of arbitrary arrays of empty lists, 
and included it for interested people here. Alas this function has experimental 
status yet. May be there are errors or bugs, but in general this would be the 
direction to go for this purpose.

If you have knowledge of an equivalent standard function in GAP I would be 
grateful to get feedback.

Best regards, Rudolf Zlabinger
Array:=function(bounds)

# creates an array of empty lists of arbitrary nesting levels (dimensions)
# and bounds for each level
# bounds is a list of positive integers determining the length of each dimension
# the length of bounds is the dimension of the array

# at element level the dimension of the array is 1 higher, 
# as the last level are also empty lists

local array,IterateArray;

IterateArray:=function(array,bounds) 

# iterative call for decreasing levels of array and bounds

local i,dim,boundsrecall;

# i.. index, 
# dim the recent level of bounds, 
# boundsrecall.. shortened bounds for recalls

dim:=Length(bounds);                   # the varying length of bounds

for i in [1..bounds[1]] do              # 1 recallcascade for one add

  Add(array,[]);                         # enlarging the recent level of array
 
  if dim>1 then                          # dim=1 is the last level

    boundsrecall:=bounds{[2..dim]};        # shorten bounds for next level  
    IterateArray(array[i],boundsrecall);   # recursion for the next lower level 
of array   

  fi;                                    # end of dimension > 1 clause

od;                                    # end of bound loop

return array;
end;


array:=[];


array:=IterateArray(array,bounds);      # starting call of add cascade 


return array;
end;
_______________________________________________
Forum mailing list
[email protected]
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to