I've always called the block in #inject:into: the *combining* function.
Perhaps the reason I don't think of it as a "reducing" function is that
setOfSets inject: Set new into: [:acc :each | acc union: each]
has a block that combines its arguments in a way that makes the result
bigger, not smaller.
Dear Richard,
sorry for the delayed reply and thanks for your thoughts. I wrapped my head
around your suggestions and tried a few thing to see how the play out in code.
I tend towards the following names.
- Reducing function (a role) is a binary block / object that responds to
#value:value:
Let
initial :: a
combine :: a -> b -> a
finish :: a -> c
then
(finish . foldl combine initial) :: Foldable t => t b -> c
This appears to be analogous to your 'reduce with completion'.
What *can* be done with composition generally *should* be done
with composition; I really don't see any a
Hi Richard!
Thanks for sharing your thoughts.
There's a reason why #inject:into: puts the block argument
last. It works better to have "heavy" constituents on the
right in an English sentence, and it's easier to indent
blocks when they come last.
Nice, I never though of it this way.
#reduce: aReduction
Are you saying that aReduction is an object from which
a dyadic block and an initial value can be derived?
That's going to confuse the heck out of Dolphin and Pharo
users (like me, for example). And in my copy of Pharo,
#reduce: calls #reduceLeft:, not #foldLeft:
The reason I came up with the naming question in the first place is that I
(finally !) finish my port of Transducers to Pharo. But currently, I am running
into a name clash. Maybe you have some good ideas how to resolve the following
situation in a pleasant way.
- #fold: exists in Pharo and is