Array generation

Andreas Rossberg rossberg at google.com
Mon Jul 11 04:03:15 PDT 2011


On 10 July 2011 22:23, David Herman <dherman at mozilla.com> wrote:
> Another common and useful fusion of two traversals that's in many Schemes is map-filter or filter-map:
>
>    a.filterMap(f) ~~~ [res for [i,x] of items(a) let (res = f(x, i)) if (res !== void 0)]
>
> I rather arbitrarily chose to accept both null and undefined here as way to say "no element" -- a reasonable alternative would be to accept *only* undefined as "no element".

\bikeshed{ The SML lib calls this one mapPartial, which I think is a
much better name. }

/Andreas


More information about the es-discuss mailing list