[ruby-talk:02353] Re: Function of Array.filter surprises me

From: schneik@...
Date: 2000-04-03 20:03:35 UTC
List: ruby-talk #2353

mengx@nielsenmedia.com writes:
# >
# > I have to admit `filter' is not a best name; some proposed `collect!',
# > but I don't feel it's not collecting anything.
# >
# >
# >                                matz.
#
# Would convert/convert! or transform/transform! be better that
collect/filter?
# Of course they could mean something like "to_s", but in iterator context,
# I will not be confused.

Well, filter once kind of made a sort of idiosyncratic sense in the distant
past when it was a semi-common UNIX idiom for something like a
sed/awk/nroff stage in a pipeline.

However, I much prefer Perl's term "map" (as in "map one set of things into
another set of things"). Map is also used in a number of other languages as
well, IIRC. I also like map because it is briefer than convert or
transform, and because this term is commonly used in mathematics to
designate functional transformations.

So let's map/map!

Conrad Schneiker
(This note is unofficial and subject to improvement without notice.)


In This Thread

Prev Next