All pastes #994156 Raw Edit

Unnamed

public php v1 · immutable
#994156 ·published 2008-04-23 04:34 UTC
rendered paste body
<?phpfunction sum($term, $a, $next, $b){	if (function_exists($term) && function_exists($next))	{	        var_dump($next);                $sum = 0;                for ($c = $a; $c <= $b; $c = $next($c))                {			$sum += $term($c);	        }	}       		else	{		return (-1);	}        return ($sum);}function identity($x) { return ($x); }function increment($x) { return (++$x); }function outp($contents){        echo('<p>'.$contents.'</p>');}echo('<html><head><title>SICPHP</title></head><body>');outp('Sum of 1..5 = '.sum(identity, 1, increment, 5));outp('Sum of 1"OOPS"5 = '.sum("identity", 1, "OOPS", 5));outp('Ahem');outp('Sum of increment(1, 3, 5) = '.sum("increment", 1, create_function('$x', 'return ($x + 2);'), 5));echo('</body></html>');?>