Questions tagged [fold]

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

In functional programming, a fold, also known variously as , 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.

1159 questions
-3
votes
2 answers

Could someone explain me a haskell's function

I found a solution to my exercise on the internet but I'm not sure what is it. The result is correct though. foldr (\n acc -> (n*10):acc) [] Could someone explain me exactly the steps of that function please? This should multiply all the elements…
Bobys
  • 677
  • 1
  • 14
  • 37
-4
votes
2 answers

Spliting a list in Haskell with fold?

Need to implement a split with foldl or foldr. For example: split [2, 4, 6, 8, 7] into ([2, 6, 7], [4, 8]).
-4
votes
1 answer

pp not working on ruby file

How do I get pp to wrap (limit) the line lengths to 79 characters as the pp documentation says? The following example demonstrates that pp does not limit the output to default length 79 as stated in the pp documentation. (1) Put the following code…
jasnow
  • 78
  • 5
-6
votes
1 answer

What are the design considerations for the lack of std::maximum?

The C++ standard library supports various function objects, including the associative binary functors std::plus and std::multiplies, which are useful arguments for various general fold algorithms, such as std::accumulate, std::reduce, or…
Walter
  • 44,150
  • 20
  • 113
  • 196
1 2 3
77
78