Many years ago I briefly skimmed a physical book (or perhaps a preprint?) on programming in Racket that included lots of really unique uses of map and fold (reduce) in particular, although it had plenty of genuinely unique tricks with curried (curryed?) functions et al. -- all of these without (notable) loss of generality across language.I distinctly recall amazingly tiny and elegant ways to traverse and manipulate trees, produce huffman encodings, generate a min/max heap and much more. If my memory serves, many of them relied on folding up a function (e.g, the value being accumulated and ultimately returned was an anonymous function), ultimately there was some very general and nontrivial rule concerning map and fold individually that was rooted in computer science.In trying to scrape my brain for the list all I came up with was a very lame rehashed version of a recursive function to extract the leaves from a tree.(define-fn get-leaves     (mapc (lambda g            (print g#value)           get-leaves)      graphs)alternativelyfunction getLeaves(node) {  if (node.children == null) console.log(node.value);  else node.children.map(getLeaves)}If someone knows the name of this article or book, that would be the absolute greatest. If not, I'd love a list of unique and powerful insights or snippets involving map/fold or otherwise related concepts.I'll ask the reader to omit the generic uses of map and reduce (apply-to or summing of lists, building an associative array, etc) that most are already familiar with
Tricks, Tips and Nontrivial Insights with Higher-Order Functions
algorithms;reference request;functional programming