aList 1D 2D differences between Numbers, Char, Words

11 views
Skip to first unread message

Bert Mariani

unread,
Feb 1, 2026, 4:15:56 PM (9 hours ago) Feb 1
to The Ring Programming Language
Hello Mahmoud et ALL

See attached. It will detect and print 1D or 2D List format.
      TestArray1D2D-1.ring

Seems to print different ways depending if  
aList is Numbers, Letters,  Words  and !D or 2D
Calls Func DebugArray(arrayList)

Can anybody explain the behaviour ?

==========================
Input Lists

aNum1D  = [9,8,7,6,5,4,3,2,1]
aChar1D = ["a","b","c","d","e","f","g","h","i"]

aNum2D = [[1,2,3],
          [4,5,6],
          [7,8,9]]
           
aWord1D = ["able","baker","charlie","dog","easy","fox","george","harry","igloo"]    

aWord2D = [[ "george","harry","igloo" ],
           [ "dog","easy","fox"  ],
           [ "able","baker","charlie" ]] 

================================
OUTPUT

aNum-1D: ===== Horizontal Numbers  <<< GOOD
1D Items: 9x0
9 8 7 6 5 4 3 2 1

aChar-1D: ===== Vertical Letters  <<<  Strange 
2D Items: 9x1
a
b
c
d
e
f
g
h
i


aNum-2D : ===== Matrix of Numbers  <<< GOOD
2D Items: 3x3
1 2 3
4 5 6
7 8 9


aWord-1D: ===== Vertical Words with Spaces between Letters <<< STRANGE
2D Items: 9x4
a b l e
b a k e r
c h a r l i e
d o g
e a s y
f o x
g e o r g e
h a r r y
i g l o o


aWord-2D: ===== Matrix of Words <<< GOOD
2D Items: 3x3
george harry igloo
dog easy fox
able baker charlie

=======================
TestArray1D2D-1.ring

Ilir Liburn

unread,
Feb 1, 2026, 6:07:19 PM (7 hours ago) Feb 1
to The Ring Programming Language
Hello Bert,

error is in your DebugArray function, you are assuming first element can't have length because it is an array, but actually it is a string which also have length.

Avoid try-catch whenever you can.

Func DebugArray(arrayList)

    nRow = 0  nCol =0
   
    nRow = len(arrayList)  

    if ! islist(arraylist[1])  // 2D has nCol
        See "1D Items: "+ nRow +"x"+ nCol +nl  
            for i = 1 to nRow        // 1D has No Col
                See ""+ arrayList[i] +" "  
            next
        Return  
    ok
       
    nCol = len(arraylist[1])  
    See "2D Items: "+ nRow +"x"+ nCol +nl
   
    for subList in arrayList
       for i = 1 to len(subList)
           See ""+ subList[i] +" "  
       next
       See nl
    next
   
Return  


Greetings,
Ilir

Bert Mariani

unread,
Feb 1, 2026, 11:01:18 PM (2 hours ago) Feb 1
to The Ring Programming Language
Thanks Ilir

Looks better now.
Matches expectations

     -   if ! islist( arraylist[1] )      // 2D has nCol
Is a better solution to determine Flat List

================================
Output

Num-1D: ===== Horizontal Numbers

1D Items: 9x0
9 8 7 6 5 4 3 2 1

aChar-1D: ===== Horizontal Letters
1D Items: 9x0

a b c d e f g h i

aNum-2D : ===== Matrix of Numbers
2D Items: 3x3
1 2 3
4 5 6
7 8 9

aWord-1D: ===== Horizontal  Words
1D Items: 9x0
able baker charlie dog easy fox george harry igloo


aWord-2D: ===== Matrix of Words
2D Items: 3x3
george harry igloo
dog easy fox
able baker charlie

Reply all
Reply to author
Forward
0 new messages