How to resolve the algorithm Array concatenation step by step in the VBScript programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Array concatenation step by step in the VBScript programming language

Table of Contents

Problem Statement

Show how to concatenate two arrays in your language.

If this is as simple as array1 + array2, so be it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Array concatenation step by step in the VBScript programming language

Source code in the vbscript programming language

Function ArrayConcat(arr1, arr2)
    ReDim ret(UBound(arr1) + UBound(arr2) + 1)
    For i = 0 To UBound(arr1)
        ret(i) = arr1(i)
    Next
    offset = Ubound(arr1) + 1
    For i = 0 To UBound(arr2)
        ret(i + offset) = arr2(i)
    Next
    ArrayConcat = ret
End Function

arr1 = array(10,20,30)
arr2 = array(40,50,60)
WScript.Echo "arr1 = array(" & Join(arr1,", ") & ")"
WScript.Echo "arr2 = array(" & Join(arr2,", ") & ")"
arr3 = ArrayConcat(arr1, arr2)
WScript.Echo "arr1 + arr2 = array(" & Join(arr3,", ") & ")"

  

You may also check:How to resolve the algorithm String interpolation (included) step by step in the Picat programming language
You may also check:How to resolve the algorithm LZW compression step by step in the C# programming language
You may also check:How to resolve the algorithm Web scraping step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Cantor set step by step in the Excel programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the Fe programming language