Skip to content

Instantly share code, notes, and snippets.

@halbuki
Last active September 1, 2022 17:41
Show Gist options
  • Save halbuki/3243638af945b4e8edf85bebc6b56887 to your computer and use it in GitHub Desktop.
Save halbuki/3243638af945b4e8edf85bebc6b56887 to your computer and use it in GitHub Desktop.
Excel Lambda functions for array manipulation
REPLACENTH = LAMBDA(array, xnew, trow, [tcol],
LET(
tcol, MAX(tcol, 1),
MAKEARRAY(
ROWS(array),
COLUMNS(array),
LAMBDA(irow, icol,
IF(
AND(irow = trow, icol = tcol),
xnew,
INDEX(array, irow, icol)
)
)
)
)
);
ARRMAPLAM = LAMBDA(array, transf, [cond],
MAKEARRAY(
ROWS(array),
COLUMNS(array),
LAMBDA(ir, ic,
IF(
IF(
ISOMITTED(cond),
TRUE,
cond(array, ir, ic)
),
transf(array, ir, ic),
INDEX(array, ir, ic)
)
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment