RM = Raul Miller, RC = Roy Crabtree, TB = Terrence Brannon

RM>  A ([: > process_prime~&.>/ <"0@|[EMAIL PROTECTED] , <@[) 2 }.i.28

RC>  after i.28, the rest of it seems like a hole lotta syntax  
RC>  for what should be reverse, append, scan/reduce....

Reverse, append, and reduce is precisely what Raul's code does. 

Whether it's "too much syntax" is subjective (though a number of Jers have 
wished for a primitive that does this).

TB>  amen. it cracks me up when someone knows so much that he/she 
TB>  overlooks the simple elegant solutions.

I am not sure to what or whom you refer with this statement.  If you mean that 
this is the simple, elegant solution:

RC>  Instead of  (((A pp 2) pp 3) pp4)...  what if you stated 
RC   it as  4 pp 3 pp 2 pp A

and that Raul missed it, then I reiterate:

Reverse, append, and reduce is precisely what Raul's code does. 

It's a well-established pattern in J code.  You might take the time to read 
about LoopWithInitial in JfC:

   http://www.jsoftware.com/help/jforc/loopless_code_vi_temporary_v.htm

and the "2 f 3 f 4 f m" thread:

   http://www.jsoftware.com/pipermail/programming/2006-May/002227.html

(read the whole thread; that's just the initial message). You might also want 
to add some new utilities to your drawer.  I use Jose Quintana's adverb seq  :

   http://www.jsoftware.com/pipermail/general/2002-September/012293.html

Here's modified version,  seqb  , which is less general but leverages a 
characteristic of your problem:

           seqb  =: each / ( @:(<"_1@:[ , <@:]) )  (>@:)
           sieve =: process_prime ~ seqb~ 2 + i.@:-@:#
           isv   =: I.@:sieve
           
           isv A
        2 3 5 7 11 13 17 19 23 27

-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to