A Curried Composition Puzzle

The author presents a curried composition puzzle in four different languages – lambda calculus, Haskell, Scheme, and Javascript – challenging readers to express a three-fold composition purely in terms of two-fold composition. The author explains the concept of currying functions and provides examples in Javascript. By reframing the problem as tree nodes and rewriting rules, the author arrives at a solution that may seem unintuitive but works effectively. The author concludes by posing two more puzzles, prompting readers to consider generalizing the solution to an n-fold composition function and exploring the limitations of composing three functions in reverse order.

https://franklin.dyer.me/post/212

To top