Re: New names for some operations
taylanbayirli@xxxxxx 13 Sep 2015 20:04 UTC
Shiro Kawai <xxxxxx@gmail.com> writes:
> On Sun, Sep 13, 2015 at 2:13 AM, Taylan Ulrich Bayırlı/Kammer
> <xxxxxx@gmail.com> wrote:
>
> - hashtable-fold -> hashtable-sum
>
> Once again, argument order for one, and more importantly different
> semantics. "Sum" is a good name because it makes it obvious that
> the given procedure should be associative and commutative in a
> sense.
>
>
> Another option can be hashtable-reduce.
>
> "Reduce" has precedence in CL and some other languages but the usage
> seems a bit more liberal than "fold" - some allows omitting initial
> value, for example. Well, srfi-1 has reduce, unfortunately. But the
> combined name xxx-reduce hasn't been used as much as xxx-fold in
> Schemes.
Hmm, I guess that's a good point. I've been suggested 'reduce' before,
but ignored the consideration because our hashtable-reduce would have
quite different arguments from SRFI-1 reduce. But you're right in that
it's not used much outside SRFI-1, so that should actually be fine.
> What's bothers me on sum is that it's not only suggest associativity
> and commutativity, but also implies the elements (to be fold) and the
> accumulated value are of the same type. In hashtables, the elements
> are actually a key and a value, so confusion is less likely, but if we
> want to extend xxx-sum for a general name of the "Container-first"
> pattern, the implication may get in the way.
Indeed. I will change it to -reduce then.
Thanks!
Taylan