notf

function notf( f ) --> mfunc

Description

Takes a function mfunc and returns a function that calls f and negates the result with not.

Parameters

f

Function that returns true or false.

Return Values

mfunc

Wrapper function that negate the result of f.

Code

--ZFUNC-notf-v1
local function notf( f ) --> mfunc
   return function ( ... )
      return not f( ... )
   end
end

return notf

Examples

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

f = notf( function () return false end )
t.ok( f() )

f = notf( function () return true end )
t.nok( f() )

f = notf( function ( b ) return b end )
t.ok( f( false ) )
t.nok( f( true ) )

t.done()