Jump to content

Adding 2 arrays together


Recommended Posts

Just as the function _ArrayConcatenate concatenates two arrays - either 1D or 2D with the same number of columns.
This function _ArrayColConcatenate concatenates two arrays - either 1D or 2D with the same number of rows.
 

#include <array.au3>

Local $a1 = '1|2'
Local $ab1 = StringSplit($a1, "|", 2)
_ArrayDisplay($ab1, "First 1D array")

Local $b1 = '3|4'
Local $ab2 = StringSplit($b1, "|", 2)
_ArrayDisplay($ab2, "Second 1D array")

_ArrayColConcatenate($ab1, $ab2)
_ArrayDisplay($ab1, "Two 1D arrays concatenated column-wise")

Local $b1 = '5|6'
Local $ab3 = StringSplit($b1, "|", 2)
_ArrayDisplay($ab3, "Third 1D array")

_ArrayColConcatenate($ab1, $ab3)
_ArrayDisplay($ab1, "2D & 1D arrays concatenated column-wise")

_ArrayColConcatenate($ab1, $ab1)
_ArrayDisplay($ab1, "2D array doubled column-wise")


Func _ArrayColConcatenate(ByRef $avArray_Tgt, $avArray_Src)
    _ArrayTranspose($avArray_Tgt)
    _ArrayTranspose($avArray_Src)
    _ArrayConcatenate($avArray_Tgt, $avArray_Src)
    _ArrayTranspose($avArray_Tgt)
EndFunc   ;==>_ArrayColConcatenate
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...