Vector.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 a vector containing results of calling
function. For keep_unmatched=True, the length of the resulting vector
is the maximum of the lengths of the input vectors. For
keep_unmatched=False, the length of the resulting vector is the minimum
of the lengths of the input vectors.
Arguments
that: The vector 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 vectors - the last elements of the longer vector will haveNothings for elements in the smaller one. If set toFalse, the result will have as many elements as the smaller of the two vectors - the additional elements of the larger vector will be discarded. The default value isReport_Unmatchedwhich means that the user expects that two vectors 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 vector, 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 vectors.
[1, 2, 3].zip [4, 5, 6] (+)
When the function is not provided, it defaults to creating a pair
of both elements.
[1, 2, 3].zip [4, 5, 6] == [[1, 4], [2, 5], [3, 6]]
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.