Array ‘By Element’ functions

RBYROW

Reference

» Reference, Discussion, & Example Applications:

About

Applies a helper lambda function by row, on a 2-D array.

Similar to SPILLBYROWS only without the extensive error management.

Inputs:

  • ar : array
  • fn : function lambda helper argument LAMBDA(x, fn(x))

Code

M.S. Excel
RBYROW = LAMBDA(ar, fn,
    LET(
        a, IF(ar = "", "", ar),
        c, --(COLUMNS(a) = 1),
        r, REDUCE(
            0,
            SEQUENCE(ROWS(a)),
            LAMBDA(v, i, VSTACK(v, fn(INDEX(a, i, c))))
        ),
        DROP(IFNA(r, ""), 1)
    )
);