>>>>> "AS" == Ariel Scolnicov <[EMAIL PROTECTED]> writes:
>> If the original list has no elements, C<reduce> immediately returns C<undef>.
AS> I like everything except this part. Reducing an empty list should be
AS> an error.
AS> Returning undef (or anything else, really) breaks the algebraic
AS> equivalence that
AS> f((reduce \&f, LIST), $x) eq (reduce \&F, LIST, $x)
I don't see it.
1 == f((reduce +, undef), 1) == reduce +, undef, 1
I really would like to be able to pass around an empty list and get
a _reasonable_ answer. Having to check the list for emptyness before
passing it in just seems dirty. One doesn't have to do this for anyother
looping operator in the language.
for (@empty) {}
grep {} @empty
map {} @empty
etc.
AS> Since this is the single most important property of reduce (indeed, it
AS> is the *only* property of reduce), I don't see what we get by breaking
AS> it.
And if your rule is true, then your induction proof is wrong. A list
can be empty.
AS> Also, the RFC should specify that the function is always evaluated in
AS> a scalar context (for things to make sense).
Why? reduce should be able to reduce a set of matrices to a matrix. Or
actually any aggregate (plural whatzit).
I think this is too limiting.
Depending upon the context reduce should return undef, an empty list,
or other empty plural whatzit.
<chaim>
--
Chaim Frenkel Nonlinear Knowledge, Inc.
[EMAIL PROTECTED] +1-718-236-0183