[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: Lua 5.3 -- Named Return Values
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 20 Nov 2013 23:35:56 +0200
2013/11/18 Stéphane Aulery <lkppo@free.fr>:
> I do not know if this is doable, but I would find it convenient to name
> the return values of functions to facilitate code maintenance.
Simply use informative variable names.
function statistics(x)
local mean, variance, standard_deviation = 0,0,0
for k=1,#x do mean = mean+x[k] end
mean = mean/#x
for k=1,#x do variance = variance+(x[k]-mean)^2 end
variance = variance/#x
standard_deviation = sqrt(variance)
return mean, variance, standard_deviation
end