c#,functional-programming,catamorphism
LINQ's Aggregate method has the signature T Aggregate<T>(IEnumerable<T> source, Func<T, T, T> accumulator) So the corresponding unfolding would be IEnumerable<T> Unfold<T>(T seed, Func<T, Nullable<T>> accumulator) { Nullable<T> nextValue = new Nullable<T>(seed); while (nextValue.HasValue) { yield return nextValue.Value; nextValue = accumulator(nextValue); } } In functional programming, folding and unfolding must include...