Hi,
That's fine, I think it was already shot down owing to the supposedly
dubious utility of supporting higher arities in .reduce()
By the way, I submitted the patch because the error message had (and
still has) the "for now" wording when you try any other arity. But
after I submitted the patch I was asked to defend non-binary reduce.
After scratching my head I might have replied with some mumblings
about continued fractions or something, but I don't understand why I
was asked while that particular wording is still in place—either it's
binary only or it isn't, or perhaps it's just not specced.
I can appreciate the added complication in checking when a non-binary
reduce should actually terminate, and other concerns. If I knew that
the functionality was desired, I'd be happy to submit another patch.
At the moment a change in the wording in src/core/List.pm might be
advisable, line 296: "fail('can only reduce with arity 2 for now')",
dropping the "for now" if the functionality is not in fact desired.
Anyway, thanks for following up!
Best Regards,
Stephen Mosher
Quoting Will Coleda via RT <perl6-bugs-follo...@perl.org>:
On Wed Oct 27 00:22:05 2010, smosher wrote:
Hi,
Attached is a diff against rakudo/src/core/Any-list.pm which adds
support to reduce() for higher-arity functions. It ensures arity-
list agreement and is generally safe. Other than the test, the
functionality was already present... it needed two lines commented
out, two uncommented. Since tests passed and there were no
explanatory comments in the file, jnthn suggested I mail in a diff.
Here it is.
I was considering including another patch to support functions that
reduce to more than a single term, but as it turns out this is best
handled by using a [list] item instead.
Note: if the supplied function _does_ return more than a single term,
reduce() will not produce a correct result (neither this version
nor the original), but it will terminate assuming a finite list.
Regards,
Stephen
Unfortunately, this patch no longer applies against rakudo master,
so I'm rejecting the ticket.
Thanks for trying to make rakudo more awesome!
--
Will "Coke" Coleda