lambda-dev Digest, Vol 15, Issue 20 [reduce method result type]

John Nilsson john at milsson.nu
Tue Mar 8 02:16:15 PST 2011


On Tue, Mar 8, 2011 at 9:37 AM, Lawrence Kesteloot <lk at teamten.com> wrote:
> I assert that every single one of those examples would be more clearly
> (if more verbosely) expressed as a for-loop.

You might be correct. But two instinctive retorts:

a) A fold as IoC lets you handle concerns such as resource managment
on the other end of the call. F.ex. iterating over an open resultset
from a DB.

b) A fold is clearer for point free declarations. And generally more
composable Ex:
sum = fold 0 +

BR,
John


More information about the lambda-dev mailing list