On 5/22/07, Terrence Brannon <[EMAIL PROTECTED]> wrote:
Raul Miller <rauldmiller <at> gmail.com> writes:
> You mean like this?
>    A ( [: > process_prime~&.>/ <"0 @ |. @ ] , < @ [) 2}.i.28

Once again, you have completely out-classed me. I will need to do
some serious head-scratching before I understand what you are doing.

Well... first off, I goofed.  I didn't test the code (I did this
without definitions
for A and process_prime).  I think this should work though:

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

Second off, if something is confusing, looking at the data usually helps.
For example, cutting the inner train, two verbs at a time, until I get rid
of process_prime:

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

And, substituting an arbitrary value for A:
     'A' (<"0@|[EMAIL PROTECTED] , <@[) 2}.i.28

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+-+-+-+-+-+-+-+-+
|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|A|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+-+-+-+-+-+-+-+-+

Basically, I've put each of the arguments in boxes, and arranged them
so a right-to-left scan will process them in the right order.  Note also
that I'm using
  process_prime~&.>/

Here's how those adverbs kick in:
  /   process the data in from right to left, using the dyad:
 &.> which works inside the boxes with the dyad:
 ~   swapping left and right arguments with the dyad: process_prime

Once that's all done, my result is in a box,  I have to unbox it for the
final result.

I hope this helps (and I hope I did not make any other mistakes).

here is the algorithm - http://www.nist.gov/dads/HTML/sieve.html

With that specification, I'd be tempted to implement it as:

sieve=:3 :0
 r=.(y+1){.1 1
 for_prime.i.&.(p:inv)y do.
   r=.1 ((prime*}.>:i.y<[EMAIL PROTECTED]))} r
 end.
 r
)

Or, tacitly, ... nah, I don't want to overwhelm you (but the basic technique
is the same one I illustrated above -- using &.>/

Of course, I'm being a bit silly, but I guess that's because I feel the
concept is a bit silly.

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

Reply via email to