Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

ring Creating a Multi-Dimensional Array using List

###---------------------------------------------------------
### Create Array -- Dimensions Any Size:  3D, 4D, 5D etc

dimList = [4,3,4]
bList   = createDimList(dimList)

###---------------------------------------------------------
### Populate the arrays using a counter 1 ,  4x4x4 = 256 , 2x3x4x5x6 = 720

Counter = 1

for Col=1 to dimList[1]
  for Row=1 to dimList[2]
    for Dep=1 to dimList[3]
            blist[Col][Row][Dep] = Counter
            Counter++
    next
  next
next

###-----------------------------------------------
### Print the array elements in block format

for Col=1 to dimList[1]
  for Row=1 to dimList[2]
    for Dep=1 to dimList[3]
            See bList[Col][Row][Dep] See " "
    next
    See nl
  next
    See nl
next

###===========================
### FUNCTIONS

###-----------------------------------------------------------------------
### Recursive Create a Dimension Array
### Call by passing an array of dimensions: dimList = [2,3,4,5]
### Drop the first entry every iteration call, making newParms
###
### Example:
###    dimList = [4,2,3,2]                <<< Number and size of dimensions in array format
###    bList   = createDimList(dimList)   <<< Call using the array as input

func createDimList(dimArray)

     sizeList = len(dimArray)

     newParms = []
     for i = 2 to sizeList
        Add(newParms, dimArray[i])
     next

     alist = list(dimArray[1])

     if sizeList = 1
        return aList
     ok

     for t in alist
         t = createDimList(newParms)
     next

return alist
Comment

PREVIOUS NEXT
Code Example
Python :: ring open another file 
Python :: ring raise an exception 
Python :: difflib get close matches 
Python :: DELETE c1 FROM tablename c1 INNER JOIN tablename c2 WHERE c1.id c2.id AND c1.unique_field = c2.unique_field; 
Python :: qtextedit unicode 
Python :: for loop the string from reverse order and skipping last element in string python 
Python :: ring Trace library usage to pass an error 
Python :: how to insert a character into a string in python 
Python :: How to Load Any HuggingFace Model in spaCy 
Python :: matplotlib plot dpi - change format to retina instead of svg 
Python :: get feature names from one hot encoder 
Python :: insertar valor python 
Python :: python 2nd order ode 
Python :: idiomatic python 
Python :: how to split string into list conditionally+python 
Python :: how to hash out a big paragraph in vs code python 
Python :: selenium options to remember user 
Python :: defaultdict python inport 
Python :: python opendatasets 
Python :: find max, min character 
Python :: get list of all document in django-elasticsearch-dsl 
Python :: convert to lowercase command python 
Python :: “no such column” after adding a field to the model 
Python :: sending whatsapp message from python notebook 
Python :: how to insert an array as a parameter in python 
Python :: how can i display the context data returned by the view in the template 
Python :: string to 2d array python 
Python :: How to Empty a Set in Python Using the clear() Method 
Python :: python check vpn ip address 
Python :: how to check if a function is callable in puyjom 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =