Jump to content

Higher-order functions: Difference between revisions

no edit summary
No edit summary
Line 103:
return(reverse(shift));
}
 
==[[PHP]]==
[[Category:PHP]]
 
In this simple example, an array of two values is passed and the statistical average is computed.
 
function average($arry) {
$tmp = ($arry[0] + $arry[1]) / 2;
return $tmp;
}
 
To call it:
 
$array1 = ( 5, 15 );
echo "The average is ".average($arrayl)."\n";
 
 
==[[Python]]==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.