Skip to content

Instantly share code, notes, and snippets.

@pbartxl
pbartxl / DataDictionary.txt
Last active March 27, 2025 22:23
Creates a data dictionary comprising a unique key and a thunked array that it returns using GETλ. The dictionary may be built directly using formulas but a lambda function DICTIONARYλ is provided for that purpose
/* NAME: GETλ
DESCRIPTION: Returns a data object from data-dictionary. The function takes two distinct parameter strings;
the first specifies the directory name and the second the keyword
REVISIONS: Date Developer Description
Dec 19 2024 Peter Bartholomew Original Development
*/
GETλ
= LAMBDA(dict, LAMBDA(key,
LET(
uniqueKeys, TAKE(dict,,1),
@pbartxl
pbartxl / INJECTλ.txt
Last active March 27, 2025 22:23
Multidimensional arrays are conventionally held as nested 1D arrays, but the spreadsheet can nest both rows and columns to represent a 4D arrays. INJECTλ identifies submatices and applies user provided functions and further array shaping to inner and outer arrays
/* FUNCTION NAME: INJECTλ
DESCRIPTION: Identifies submatices and applies further array shaping functions to inner and outer arrays */
/* REVISIONS: Date Developer Description
02 Nov 2024 Peter Bartholomew Initial implemention
*/
INJECTλ
= LAMBDA(nestedArr, depth, width, FNλ, BYλ, [SHPλ],
LET(
bRows, 1+QUOTIENT(ROWS(nestedArr)-1, depth),
bCols, 1+QUOTIENT(COLUMNS(nestedArr)-1, width),
@pbartxl
pbartxl / COMBINATIONAλ.txt
Created September 5, 2024 14:22
An Excel Lambda function that generates all the combinations of m objects taken from n. The result is returned as an array of binary numbers 1 = selected, 0 = omitted.
/* FUNCTION NAME: COMBINATIONAλ
DESCRIPTION:*//*Lists all comninations of m objects taken from n*/
/* REVISIONS: Date Developer Description
29 Mar 2024 Peter Bartholomew Original development
*/
/* REQUIRED: NextColumnAλ, ϑSTACKλ, THUNKλ, FINALVALUEλ,
*/
COMBINATIONAλ = LAMBDA(
// Parameter Declarations
[n],
@pbartxl
pbartxl / MAPλ.txt
Last active March 27, 2025 22:21
A version of Excel MAP helper function that will return an array of arrays
/* FUNCTION NAME: MAPλ
DESCRIPTION: Implements a version of MAP that will return an array of arrays */
/* REVISIONS: Date Developer Description
28 Aug 2024 Peter Bartholomew Adapted from BYROWλ to give MAPλ
31 Aug 2024 Peter Bartholomew JOINPAIRSλ modified to stack 2D result arrays
10 Sep 2024 Peter Bartholomew Modified to accept 3 array argumments before λ-function
15 Nov 2024 David Clements Improved branching using CHOOSE
*/
MAPλ = LAMBDA(
// Parameter Declarations
@pbartxl
pbartxl / SCANVλ.txt
Last active March 27, 2025 22:23
Excel Lambda helper functions designed to return an array of arrays (normally a #CALC! error) by retuning the nested arrays as Lambda functions (thunks) before combing them pairwise as a binary tree.
/* FUNCTION NAME: SCANVλ
DESCRIPTION: Implements a version of SCAN that will return a column of arrays */
/* REVISIONS: Date Developer Description
19 May 2024 Peter Bartholomew Original Development
06 Dec 2024 Peter Bartholomew Simplify definition of Fλ and use EVALTHUNKARRAYλ
for compatibility with MAPλ
*/
SCANVλ = LAMBDA(
// Parameter Declarations
[y₀],
@pbartxl
pbartxl / Inventory library
Created July 18, 2024 15:51
FIFO Lambda in Excel
/* FUNCTION NAME: Calculateλ
DESCRIPTION:*//**Builds tables of output costs from input and output tables*/
/* REVISIONS: Date Developer Description
01 Mar 2024 Peter Bartholomew Original Component
17 Jul 2024 Peter Bartholomew Major revision to tracking entries in combined table
*/
Calculateλ
=LAMBDA(
// Parameter Declarations
[outFlow], [inFlow], [unitCost], [option],