Dan Bron wrote: > Here's a piece of J code I adapted from some APL I came across on the net: > > (#~ ] -.@:e. [: , */~)@:(2 + i.) > > It's a monad whose input is a scalar integer. What is its output? What > does the verb do?
Primes less than or equal to y+1 (I think). The verb has the form f=:g @: h . The right hand verb h gives the list 2..y+1. Dealing with the left hand verb g: [: , */~ ravels the table of all products of y. -.@:e. is "not an element of" k=:] -.@: e. [: , */~ selects elements of y which are not elements of the raveled table. The final form of g is the fork (#~ k) which selects elements of y for which k is true. Overall, we are selecting elements of 2..y+1 which are not products of two of these values, namely the primes less than or equal to y+1. Best wishes, John ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
