Array generation

liorean liorean at
Sun Jul 10 15:09:17 PDT 2011

On 10 July 2011 22:23, David Herman <dherman at> 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".

The way I think of it is that in analogy to NaN being the Numbers that
represent no number, null is the Object that represents no object, in
other words a reasonable value to store to tell just that. The
undefined value is by analogy the value that represents no value, so
is the only value that should be a "no element".

But that might be just my way of thinking about and distinguishing the
not-a-something special cases.
David "liorean" Andersson

More information about the es-discuss mailing list