On Sun, Jan 1, 2012 at 20:38, Bill Ricker <[email protected]> wrote:
> # John Cook, Endeavour, Mathematica pseudo code
> # http://www.johndcook.com/blog/2012/01/01/2012-is-prime/

Mathematica is so powerful it can indeed look like pseudo code. That
snippet is however fully functional, if not functional in style. For
the latter you'd have something like,

  Select[Range[3, 100], PrimeQ[2 #^3 + # + 2] &]

Here Select is like perl's grep, # like perl's $_ and & delimits the
end of an anonymous function.

Answers are {3, 5, 13, 23, 25, 29, 33, 43, 45, 49, 53, 59, 69, 73, 99}
in case anyone's wondering ;-)

Paul

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to