On Jun 21, 2006, at 6:23 PM, Moe Aboulkheir wrote:
> > On Wed, 21 Jun 2006 17:55:14 -0700, Bob Ippolito <[EMAIL PROTECTED]> > wrote: >> >> On Jun 21, 2006, at 5:18 PM, Moe Aboulkheir wrote: >>> ...wanting to know the mean of a bunch of nested lists is such a >>> bizarre request that i don't think it's unreasonable to require >>> that the >>> caller flattens the arguments. >> >> That's basically a side-effect of allowing both mean([1,2,3]) and >> mean >> (1,2,3) via flattenArguments. > > i'm not so sure that the two character win of mean(1, 2, 3) over > mean([1, 2, 3]) is worth it. debugging javascript is troublesome > as it is, and returning a result for ambiguous/nonsense inputs like > 1, [2, [3]] can't help, especially when it's inconsistent with the > behaviour of similar functions in the same library - e.g. > MochiKit.Iter.sum(1, [2, [3]]) -> ValueError: "1 is not > iterable" (and confusingly, MochiKit.Iter.sum([1, [2, [3]]]) -> > "12,3" in MK 1.4) It's pretty much consistent with what Python does: >>> min(1,2,3) 1 >>> min([1,2,3]) 1 >>> sum(1,2,3) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: sum expected at most 2 arguments, got 3 >>> sum([1,2,3]) 6 I don't think the collapsing of nested array is a big deal. I wouldn't document it as a feature, it's just an implementation detail. The fact that adding a number and an array gives you a nonsense string is just something you have to live with in JavaScript. -bob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit -~----------~----~----~----~------~----~------~--~---
