Skip to content

Instantly share code, notes, and snippets.

View aelbaitam's full-sized avatar

Ali ELBaitam aelbaitam

  • Toronto
  • 19:18 (UTC -05:00)
View GitHub Profile
/*
FUNCTION NAME: SplitAmount
VERSION:1.0
AUTHOR: Mahmoud Baniasadi
WEB: www.arshad-hesabdar.ir
INSTAGRAM: @SoftwareTrain
DESCRIPTION: Split each number to a specific number.
ARGS:
array: a column include lable.
amount: amount to split to a nth number of devision.
@aelbaitam
aelbaitam / Column.FitlerBy
Created June 16, 2023 03:51
An Excel function that filters by a predicate lambda.
/* Filters a column using a predicate. If 'positions'
is set to TRUE, returns the indices of the results
instead of the values */
FilterBy =
LAMBDA(col, predicate, [positions],
LET(returnPositions, AND(NOT(ISOMITTED(positions)), positions=TRUE),
indices, SEQUENCE(ROWS(col)),
IF(returnPositions,
FILTER(indices, MAP(col, predicate)),
FILTER(col, MAP(col, predicate)))));
@aelbaitam
aelbaitam / Column.MapStack
Last active June 18, 2023 21:00
Excel Function for Column arrays to avoid Nested Array errors
/* Maps a function on the cells of the given column,
and stacks the resulting arrays.
If the resulting arrays are jagged, rows are
padded with the padding if provided else #NA.
TODO: does not account for the case where the
function application produces an error.
*/
MapStack = LAMBDA(col, fn, [padding], [stack_original],
LET(Thunk, LAMBDA(value, LAMBDA(value)),
UnThunk, LAMBDA(thunk, thunk()),