[Haskell-cafe] foldr (.) id
Nick Vanderweit
nick.vanderweit at gmail.com
Sat Oct 27 00:27:39 CEST 2012
Funny, I was thinking this morning about using something like this to convert
to/from Church numerals:
church n = foldl (.) id . replicate n
unchurch f = f succ 0
I think it's a nice pattern.
Nick
On Friday, October 26, 2012 11:41:18 AM Greg Fitzgerald wrote:
> Hi Haskellers,
>
> I've recently found myself using the expression: "foldr (.) id" to compose
> a list (or Foldable) of functions. It's especially useful when I need to
> map a function over the list before composing. Does this function, or the
> more general "foldr fmap id", defined in a library anywhere? I googled and
> hoogled, but no luck so far.
>
> Thanks,
> Greg
More information about the Haskell-Cafe
mailing list