/** * Returns a function which tests if calling one the functions with the * argument is true (short circuits) * * andf(function1, function2[... functionN]) -> function -> bool */ public static function orf() { $fns = func_get_args(); if (count($fns) == 0 || !Fn::every('is_callable', $fns)) { throw new Exception("andf expects arguments to all be callable"); } return function ($x) use($fns) { foreach ($fns as $fn) { $tmp = $fn($x); if ($tmp !== false && $tmp !== 0) { return true; } } return false; }; }