Adding a Row and a Column to a 2D LIST

12 views
Skip to first unread message

Bert Mariani

unread,
Nov 17, 2025, 10:43:32 AM (16 hours ago) Nov 17
to The Ring Programming Language
Hello Mahmoud et ALL

Is there a command for  2D LIST
To ADD a COLUMN to the right of the 2D List (or position)
To ADD a ROW to the right of the 2D List (or position)
Without creating a new 2D List

Example: Existing LIST  8x10
ADD a Row and a Column to make it  LIST 9x11

Purpose:
An Existing 2D is populated with numbers
I would like to Add the existing Columns and put the Result in a New ADDed Column
Same for the Rows -- Add the existing Rows and put the Result in a New ADDed Row

===================
aList = list(8,10)
nRows = len(aList)
nCols = len(aList[1])

for v = 1 to nRows
    for h = 1 to nCols
    aList[v][h] = (10*v) + h
next
next

for v = 1 to nRows
    for h = 1 to nCols
    See ""+ aList[v][h] +tab
next
See nl
next

====================
OUTPUT - Existing Array  8x10

BEFORE
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90

AFTER
11 12 13 14 15 16 17 18 19 20 155
21 22 23 24 25 26 27 28 29 30 255
31 32 33 34 35 36 37 38 39 40 355
41 42 43 44 45 46 47 48 49 50 455
51 52 53 54 55 56 57 58 59 60 555
61 62 63 64 65 66 67 68 69 70 655
71 72 73 74 75 76 77 78 79 80 755
81 82 83 84 85 86 87 88 89 90 855
368 376 384 392 400 408 416 424 432 440 4040

Mahmoud Fayed

unread,
Nov 17, 2025, 10:58:33 AM (16 hours ago) Nov 17
to The Ring Programming Language
Hello Bert

Ring doesn't comes with a function for this purpose 
Could be written in Ring code through a for-loop that add an item for each row (to represent the column) then add a new row

Suggestion: You could add this feature to RingFastPro using C code
Suggested syntax: 

updateList(<aList>, :resize, nRows, nCols)

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages