Top "Fold" questions

In functional programming, a fold, also known variously as reduction, accumulation, or catamorphism, is a type of higher-order function that recursively applies a transformation to a data structure, "collapsing" it to a summary value

Collapsible header in Markdown to html

Our internal git-lab wiki works with Markdown. I made several summaries of articles and want to post them in our …

markdown wiki collapse fold
right text align - bash

I have one problem. My text should be aligned by right in specified width. I have managed to cut output …

bash shell alignment text-alignment fold
Applying logical and to list of boolean values

Consider the following list of Boolean values in Scala List(true, false, false, true) How would you using either foldRight …

scala boolean logical-operators fold
foldl versus foldr behavior with infinite lists

The code for the myAny function in this question uses foldr. It stops processing an infinite list when the predicate …

haskell lazy-evaluation combinators fold
foldl is tail recursive, so how come foldr runs faster than foldl?

I wanted to test foldl vs foldr. From what I've seen you should use foldl over foldr when ever you …

optimization haskell tail-recursion combinators fold
Writing foldl using foldr

In Real World Haskell, Chapter 4. on Functional Programming: Write foldl with foldr: -- file: ch04/Fold.hs myFoldl :: (a -&…

haskell recursion fold
Why can you reverse list with foldl, but not with foldr in Haskell

Why can you reverse a list with the foldl? reverse' :: [a] -> [a] reverse' xs = foldl (\acc x-> …

haskell fold
How to fold STL container?

I need an analog of Haskell's foldl function to fold any STL containers. Expected signature is like following: template Iterator, …

c++ boost stl fold
Idiomatic construction to check whether a collection is ordered

With the intention of learning and further to this question, I've remained curious of the idiomatic alternatives to explicit recursion …

scala recursion fold idioms
Why is foldl defined in a strange way in Racket?

In Haskell, like in many other functional languages, the function foldl is defined such that, for example, foldl (-) 0 [1,2,3,4] = -10. …

recursion functional-programming scheme racket fold