[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: math.between()
- From: Shaun McVey <shaun.mcvey@...>
- Date: Tue, 22 Jun 2010 00:22:51 +0100
I think my previous atttempt was rather premature. Didn't look at all
the tests...
function math.between(a, b)
local max = math.max(a, b)
local min = math.min(a, b)
local diff = max - min
if diff == 0 then
return min;
else
return diff / 2 + min;
end
end
Can't see a function with this behaviour ever being added to the std lib though.
On Mon, Jun 21, 2010 at 11:58 PM, Romulo <romuloab@gmail.com> wrote:
> 2010/6/21 Adriano Saballa das Chagas <adrianosbl@hotmail.com>:
>> math.between(0, 1) = 0.5
>> math.between(0, 5) = 2.5
>> math.between(8, 4) = 6
>> math.between(3, 6) = 4.5
>> math.between(8, 7) = 7.5
>> math.between(0, 90) = 45
>>
>> That is what I want
>
> You kidding, right?
>