Append numbers at same position in strings

From Rosetta Code
Revision as of 03:30, 10 November 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: <br>Let given three list: <br>list1 = [1,2,3,4,5,6,7,8,9] <br>list2 = [10,11,12,13,14,15,16,17,18] <br>list3 = [19,20,21,22,23,24,25,26,27] <br>Append n...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Append numbers at same position in strings is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task


Let given three list:
list1 = [1,2,3,4,5,6,7,8,9]
list2 = [10,11,12,13,14,15,16,17,18]
list3 = [19,20,21,22,23,24,25,26,27]
Append numbers at same position in strings.
The result should be:
list = [11019,21120,31221,41322,51423,61524,71625,81726,91827][11019,21120,31221,41322,51423,61524,71625,81726,91827]

Ring

<lang ring> load "stdlib.ring" list1 = [1,2,3,4,5,6,7,8,9] list2 = [10,11,12,13,14,15,16,17,18] list3 = [19,20,21,22,23,24,25,26,27] list = []

for n = 1 to len(list1)

   str1 = string(list1[n])
   str2 = string(list2[n])
   str3 = string(list3[n])
   str = str1 + str2 + str3
   add(list,str)

next

showArray(list)

func showArray(array)

    txt = ""
    see "["
    for n = 1 to len(array)
        txt = txt + array[n] + ","
    next
    txt = left(txt,len(txt)-1)
    txt = txt + "]"
    see txt

</lang>

Output:
list = [11019,21120,31221,41322,51423,61524,71625,81726,91827][11019,21120,31221,41322,51423,61524,71625,81726,91827]
<br><br>