コード例 #1
0
ファイル: 13.php プロジェクト: henkerik/typing
function odd($x)
{
    if ($x == 0) {
        return false;
    } else {
        return even($x - 1);
    }
}
コード例 #2
0
ファイル: Fn.php プロジェクト: eschwartz/Fn
function odd()
{
    return negate(even());
}
コード例 #3
0
ファイル: lib.php プロジェクト: blackwood/vervel
/**
 * 
 */
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');
    }
}
コード例 #4
0
ファイル: function.php プロジェクト: neostoic/webdev-php
<?php

function even($var)
{
    if ($var % 2 == 0) {
        return true;
    } else {
        return false;
    }
}
var_dump(even(6));
コード例 #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);