Common sorted list: Difference between revisions

Content added Content deleted
m (→‎Excel LAMBDA: Used built-in UNIQUE)
Line 293: Line 293:
=LAMBDA(grid,
=LAMBDA(grid,
SORT(
SORT(
UNIQUECOL(
UNIQUE(
CONCATCOLS(grid)
CONCATCOLS(grid)
)
)
Line 301: Line 301:
and also assuming the following generic bindings in the Name Manager for the WorkBook:
and also assuming the following generic bindings in the Name Manager for the WorkBook:


<lang lisp>APPENDROWS
<lang lisp>CONCATCOLS
=LAMBDA(xs,
LAMBDA(ys,
LET(
nx, ROWS(xs),
rowIndexes, SEQUENCE(nx + ROWS(ys)),
colIndexes, SEQUENCE(
1,
MAX(COLUMNS(xs), COLUMNS(ys))
),

IFERROR(
IF(rowIndexes <= nx,
INDEX(xs, rowIndexes, colIndexes),
INDEX(ys, rowIndexes - nx, colIndexes)
),
NA()
)
)
)
)


CONCATCOLS
=LAMBDA(cols,
=LAMBDA(cols,
LET(
LET(
Line 353: Line 330:
LAMBDA(xs,
LAMBDA(xs,
FILTER(xs, p(xs))
FILTER(xs, p(xs))
)
)


UNIQUECOL
=LAMBDA(xs,
IF(2 > ROWS(xs),
xs,
LET(
h, INDEX(xs, 1),
r, FILTERP(
LAMBDA(x, NOT(h = x))
)(xs),

IF(OR(ISERROR(r), ISNA(r)),
h,
APPENDROWS(h)(
UNIQUECOL(r)
)
)
)
)
)
)</lang>
)</lang>