Skip to main content

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 with self.
  • function: The function used to combine pairwise elements of self and that.
  • skip_nothing: If True, Nothing values will be skipped, and a Nothing will be used at that position in the output. Otherwise, Nothing values will be passed to the function. Defaults to False.
  • keep_unmatched: If set to True, the result will include as many elements as the longer of the two vectors - the last elements of the longer vector will have Nothings for elements in the smaller one. If set to False, 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 is Report_Unmatched which 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 to True - i.e. the unmatched elements are kept with Nothing values for the other vector, but a Row_Count_Mismatch problem is also reported.
  • on_problems: Specifies how to handle any problems that arise in function.

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 in Map_Error, which contains the index at which the error occurred. In the Report_Warning case, only MAX_MAP_WARNINGS warnings are attached to result values. After that, the warnings are dropped, but a count of the additional warnings is attached in an Additional_Warnings warning.