Mark J. Reed wrote:
I'm a believer in generalizing where possible, modulo the principles
of KISS and YAGNI. The latter essentially means "at least make it
general enough that you can extend it later without major retooling if
it turns out YNIAA.".  It's pretty surprising what can turn out to be
useful, so I've never been swayed by arguments from "what is it good
for?"...
Something I'm wondering, though, realistically how often would one actually
be reducing on an operator that is not associative?  What practical use is
there for [-] (3,4,5) for example?

The reduce meta-operator over - in APL gives alternating sum, similarly alternating quotient for /, which only works if you right associate things.

[-] 1,2,3,4,5,6 => 1-2+3-4+5-6 # pseudo-apl

[/] 1,2,3,4,5,6 => (1*3*5)/(2*4*6) #pseudo-apl

note that would break the perl 6 simple rule that [-] 1,2,3 => 1-2-3, but gives something much more useful. There currently is no easy way to do alternating sum/quotient in perl6.

--
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Reply via email to