each#

swordfish.function.each()#

Apply a function (specified by func or operator) to each element of args / X / Y.

  • For matrices, calculate in each column;

  • For tables, calculate in each row;

  • For array vectors, calculate in each row;

  • For dictionaries, calculate each value.

The data type and form of the return value are determined by each calculation result. It returns a vector or matrix if all calculation results have the same data type and form, otherwise it returns a tuple.

Parameters:
  • func (Constant) – A function.

  • args (Constant) – The required parameters of func.

  • operator (Constant) – A binary operator.

  • X (Constant) – A pair/vector/matrix/table/array vector/dictionary.

  • Y (Constant) –

    A pair/vector/matrix/table/array vector/dictionary.

    X and Y must have the same dimensions.