Trees

Trees are not built into the λ-interpreter (they could be) but they can be implemented using lists to give 'fork', 'leaf', 'emptyTree', 'elt', 'left' and 'right', 'infix' and breadth-first 'BFT' tree traversals, and to create a binary search tree 'BST'.




Note that the queue, 'Q', inside 'BFT' (breadth-first traversal) is a recursively defined list, a data-structure, making this an example of a circular program [All89,All93] (corecursion).

There are more λ-calculus examples here.

References

[All89] Lloyd Allison, 'Circular Programs and Self-Referential Structures', Software Practice & Experience, 19(2), pp.99-109, doi:10.1002/spe.4380190202, arxiv:2403.01866, February 1989.
[All93] Lloyd Allison, 'Applications of Recursively Defined Data Structures', Australian Computer Journal, 25(1), pp.14-20, arxiv:2206.12795, 1993.
And other publications.