You are viewing a single comment's thread. Return to all comments →
pretty cool!, a little more readable for me:
$res = array_reduce($arr, function($carry, $val) {
($val>0 and carry[0]++) or ($val<0 and $carry[1]++) or (!val and $carry[2]++); return $carry;},[]);
printf ("%f\n%f\n%f", $res[0]/$n, $res[1]/$n, `$res[2]/$``n);
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
pretty cool!, a little more readable for me:
$res = array_reduce($arr, function($carry, $val) {
($val>0 and carry[0]++) or ($val<0 and $carry[1]++) or (!val and $carry[2]++); return $carry;},[]);
printf ("%f\n%f\n%f", $res[0]/$n, $res[1]/$n, `$res[2]/$``n);