Example #1
0
 * Calls f and catches the A that it throws.
 * @ignore
 */
function g()
{
    try {
        f();
    } catch (A $exception) {
        // ...
    }
}
//}>x
if (realpath($argv[0]) == realpath(__FILE__)) {
    printf("sum(10) = %d\n", Example::sum(10));
    printf("horner([2,4,6], 2, 57) = %d\n", Example::horner(array(2, 4, 6), 2, 57));
    printf("horner2([2,4,6], 2, 57) = %d\n", Example::horner2(array(2, 4, 6), 2, 57));
    printf("factorial(10) = %d\n", Example::factorial(10));
    printf("findMaximum([3,1,4,1,5,9,2], 7) = %d\n", Example::findMaximum(array(3, 1, 4, 1, 5, 9, 2), 7));
    printf("gamma = %f\n", Example::gamma());
    printf("geometricSeriesSum1(10, 6) = %d\n", Example::geometricSeriesSum(10, 6));
    printf("geometricSeriesSum2(10, 6) = %d\n", Example::geometricSeriesSum2(10, 6));
    printf("geometricSeriesSum3(10, 6) = %d\n", Example::geometricSeriesSum3(10, 6));
    $arg = array(2, 4, 6, 8);
    Example::prefixSums($arg, 4);
    printf("prefixSums([2,4,6,8], 4) = %s\n", join(',', $arg));
    printf("fibonacci1(5) = %d\n", Example::fibonacci(10));
    printf("fibonacci2(5) = %d\n", Example::fibonacci2(10));
    printf("fibonacci3(5) = %d\n", Example::fibonacci3(10));
    printf("fibonacci4(5, 2) = %d\n", Example::fibonacci4(10, 2));
    $arg = array(3, 1, 4, 1, 5, 9, 2);
    $buckets = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);