by shaunxcode · 18y ago · 0 comments
Such as:
//python version:
noprimes = [j for i in range(2, 8) for j in range(i*2, 50, i)]
primes = [x for x in range(2, 50) if x not in noprimes]
//phparrayplus version:
$noprimes = xR(2,8)->for_each('xR($x*2,50,$x)->out()')->flatten();
$primes = xR(2,50)->diff($noprimes);
//common lisp:
(loop for x from 0 to 100 if (> (* x x) 3) collect (* 2 x))
//phparrayplus version:
$C = xR(100)->if_only('($x*$x) > 3')->for_each('2*$x');
//factorial in phparrayplus, nothing else to compare this too - just cool:
function fac($n){
return xR(1,$n)->reduce('$x*$y');
}