Array generation

David Herman dherman at mozilla.com
Sun Jul 10 14:51:05 PDT 2011


>    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".

Oops, I meant to say, I rather arbitrarily chose to accept *only* undefined and a reasonable alternative would be to accept null *or* undefined, i.e.:

    a.filterMap(f) ~~~ [res for [i,x] of items(a) let (res = f(x, i)) if (res != null)]

I think I prefer the only-undefined version.

Dave



More information about the es-discuss mailing list