Not having them used them all that much, I’m not quite sure about all the ways
lambda-definitions can be used (other than map/collect/do/lightweight local function syntax). For anyone interested in posting some examples:
-
provide explanations to help readers understand how lambda-definitions are being used;
-
preferred languages for the examples: Python, Smalltalk, Haskell.
You can make a functional data structure out of lambdas. Here is a simple one – a functional list (Python), supporting
addandcontainsmethods:I just coded this quickly for fun – notice that you’re not allowed to add any falsy values as is. It also is not tail-recursive, as a good functional structure should be. Exercises for the reader!