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( "taptest" )
local notf = require( "notf" )

f = notf( function () return false end )
t( f(), true )

f = notf( function () return true end )
t( f(), false )

f = notf( function ( b ) return b end )
t( f( false ), true )
t( f( true ), false )

t()