inrange

function inrange( num, min, max ) --> res

Description

Checks if the number num is inside the with min and max defined number range. The number must be greater or equal min and lower or equal max.

Parameters

min

The lower border for the number.

num

The number that is checked.

max

The upper border for the number.

Return Values

res

true if num is greater or equal min and lower or equal max, otherwise false.

Code

--ZFUNC-inrange-v1
local function inrange( num, min, max ) --> res
   if num >= min and num <= max then
      return true
   else
      return false
   end
end

return inrange

Examples

local t = require( "tapered" )
local inrange = require( "inrange" )

local min = 2
local max = 11

t.ok( inrange( 2, min, max ) )
t.ok( inrange( 7, min, max ) )
t.ok( inrange( 11, min, max ) )

t.nok( inrange( 1, min, max ) )
t.nok( inrange( 12, min, max ) )

t.done()

See also