[squeak-dev] Re: Collection's #fold: vs #reduce:
Levente Uzonyi
leves at elte.hu
Tue Nov 2 19:59:35 UTC 2010
On Tue, 2 Nov 2010, Andreas Raab wrote:
> On 11/2/2010 11:31 AM, Levente Uzonyi wrote:
>>> more cuddly) and since we don't have map: (we have collect:) I don't find
>>> the need to use reduce: compelling. But that's my preference. I won't
>>> object if you replace fold: with reduce:/ I do note that Gilad used fold:
>>> in Newspeak.
>>>
>>> What do you prefer?
>>
>> I prefer the second option, because both names are widely used, but some
>> people are only aware of the one which their previously used languages
>> have. So this way we can avoid questions like "Why isn't there a
>> method for folding in Squeak?".
>
> If you go by familiarity, reduce is by far the obvious choice. Most of the
> popular dynamic languages use reduce:
>
> PHP: http://php.net/manual/en/function.array-reduce.php
> Javascript:
> https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce
> Python: http://docs.python.org/library/functions.html#reduce
>
> What languages use fold?
Mostly functional languages. Here is a list of popular languages, that
implement fold/reduce:
http://en.wikipedia.org/wiki/Fold_(higher-order_function)#Implementation
So users of Erlang, F#, Haskell, OCaml, Scala, SML will probably look for
#fold:.
Levente
>
> Cheers,
> - Andreas
>
>
More information about the Squeak-dev
mailing list
|