Exemplo n.º 1
0
function odd($x)
{
    if ($x == 0) {
        return false;
    } else {
        return even($x - 1);
    }
}
Exemplo n.º 2
0
Arquivo: Fn.php Projeto: eschwartz/Fn
function odd()
{
    return negate(even());
}
Exemplo n.º 3
0
/**
 * 
 */
function loop(array $bindings)
{
    $args = func_get_args();
    $exprs = rest($args);
    if (!even(count($bindings))) {
        throw new Exception('Bindings should be an array with an even number of values');
    }
}
Exemplo n.º 4
0
<?php

function even($var)
{
    if ($var % 2 == 0) {
        return true;
    } else {
        return false;
    }
}
var_dump(even(6));
Exemplo n.º 5
0
<?php

// Simple variable that stores a function to return if the number is even
$even = function ($number) {
    return $number % 2 ? null : $number;
};
echo "Using first class functions the result is: " . $even(12) . "\n";
// Of course the prev example can be done imperative with a function as follows:
function even($number)
{
    return $number % 2 ? null : $number;
}
echo "Using a function the result is: " . even(12);