u/CamomileChocobo

▲ 19 r/haskell

Function that returns a list of all computed values in recursive function

I'm quite new to Haskell and I've been looking for a higher order function (or implement one myself) that returns a list of all intermediate values of a recursive function.

For example if I have a recursive factorial function fac, then doing fac 5 will return 5!.

But supposed I want to return a list of [1!, 2!, 3!, 4!, 5!] instead, how do I go about this without doing the same computation multiple times? Or is a recursive function a bad choice for this?

reddit.com
u/CamomileChocobo — 13 days ago