lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 22 June 2010 20:52, Stefan <> wrote:
> Hear, hear!
> -- Average function using arithmetic mean
> -- (using proposed math.sum function)
> function math.avg(...)
>    return math.sum(...) / select("#",...)
> end
> On a side note, I find it vaguely disappointing how many (too quick)
> responses to the original post were utterly wrong given the sample results.
> I know (hope?) we all could do better given some real effort. This seems to
> be a bit of a trend lately - of shooting from the hip with solution/sample
> code. Perhaps we should be less quick to respond and more careful with such
> responses?

Maybe, maybe not - rapid fire answers and threads like this can be fun
if you look at it from the right perspective :)

I've certainly learnt from this thread, seeing the various proposed
solutions (right and wrong) - I guess few could say they haven't. Mine
was a correct but overly verbose one, I'm quite sure Luiz won the
first prize for being correct and brief, bonus points go to the people
who wrote the various interesting (and working) generic mean()
functions, and we've also established that a math.sum() might be a
useful thing seeing that it's not too pretty replicating it in pure