LAMBDA UDTs use LAMBDA to define a custom data type. They emulate the object-oriented programming paradigm, where UDTs consist of fields and methods. These types take the form:
lambda(i,choose(i,a,b...))
Data is encapsulated inside a number of user-defined fields, listed as a,b...
in the expression above. These fields can contain any data types, including ranges, arrays, and lambda terms.
In other words, they allow the user to define collections of different kinds of data that can be used as both input and output for user-defined functions.
UDTs must be instantiated and provided data for each field to be operated on. LAMBDA UDTs can be instantiated manually or via constructor:
=let(
udt,lambda(a,b...,
lambda(i,choose(i,a,b...))
),
udt(a,b...)
)
Note that the above formula only shows instantiation. The output will be a lambda term which cannot be output to a cell.
To access data stored within a LAMBDA UDT, simply provide it with an index argument, as shown below:
=let(
udt,lambda(a,b...,
lambda(i,choose(i,a,b...))
),
udt(a,b...)(<index>)
)
The β-reduction will then supply that index to the CHOOSE
, returning the field at the desired index.
Notes
Calculation limits represent a major limitation to LAMBDA UDTs, as they are heavily LAMBDA-intensive in nature and can quickly hit the recursion limit.