Array.zip
zipthatfunctionskip_nothingkeep_unmatchedon_problems
Group: Calculations
Aliases: combine, join by row position, merge
Documentation
Performs a pair-wise operation passed in function on consecutive
elements of self and that.
The result of this function is an array containing results of calling
function. For keep_unmatched=True, the length of the resulting array
is the maximum of the lengths of the input arrays. For
keep_unmatched=False, the length of the resulting array is the minimum
of the lengths of the input arrays.
Arguments
that: The array to zip withself.function: The function used to combine pairwise elements ofselfandthat.skip_nothing: IfTrue,Nothingvalues will be skipped, and aNothingwill be used at that position in the output. Otherwise,Nothingvalues will be passed to thefunction. Defaults toFalse.keep_unmatched: If set toTrue, the result will include as many elements as the longer of the two arrays - the last elements of the longer array will haveNothings for elements in the smaller one. If set toFalse, the result will have as many elements as the smaller of the two arrays - the additional elements of the larger array will be discarded. The default value isReport_Unmatchedwhich means that the user expects that two arrays should have the same amount of elements; if they do not, the behaviour is the same as if it was set toTrue- i.e. the unmatched elements are kept withNothingvalues for the other array, but aRow_Count_Mismatchproblem is also reported.on_problems: Specifies how to handle any problems that arise infunction.
Examples
Calculate the pairwise sum of two arrays.
[1, 2, 3].to_array.zip [4, 5, 6].to_array (+)
When the function is not provided, it defaults to creating a pair
of both elements.
[1, 2, 3].to_array.zip [4, 5, 6].to_array == [[1, 4].to_array, [2, 5].to_array, [3, 6].to_array].to_array
Errors
The result of Errors thrown when executing the function depend on
on_problems:
- Report_Error: The first error is thrown, and is wrapped in
Map_Error. - No_Wrap: The first error is thrown, and is not wrapped in
Map_Error. - Report_Warning: The result for that element is
Nothing, the error is attached as a warning. Currently unimplemented. - Ignore: The result is
Nothing, and the error is ignored. Errors that are thrown when executing the supplied function are wrapped inMap_Error, which contains the index at which the error occurred. In theReport_Warningcase, onlyMAX_MAP_WARNINGSwarnings are attached to result values. After that, the warnings are dropped, but a count of the additional warnings is attached in anAdditional_Warningswarning.