[Jprogramming] a J-ish way to generalize a suffix scan
R.E. Boss
r.e.boss at planet.nl
Wed Jan 6 05:36:25 HKT 2010
If I understand you correctly, you say
for_p. x do. for_q. y do.
is as (in)efficient as
for_q. y do. for_p. x do.
Right?
I was thinking of something like doing some smart tricks on y , (x+/y) ,:
x*/y
but probably you are right and there is not much to be gained.
Thanks for pointing out.
R.E. boss
-----Oorspronkelijk bericht-----
Van: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] Namens Raul Miller
Verzonden: dinsdag 5 januari 2010 21:56
Aan: Programming forum
Onderwerp: Re: [Jprogramming] a J-ish way to generalize a suffix scan
On Tue, Jan 5, 2010 at 11:27 AM, R.E. Boss <r.e.boss at planet.nl> wrote:
> 2 3 5 (4 : '(]`(]>.x+[)`(]<.x*[))@.(*@-)/\.y')"0 _ ?.#~10
> 10 10 11 4 8 11 0 9 0 4
> 12 12 12 6 12 12 0 10 0 4
> 10 10 10 10 14 14 0 12 0 4
>
> It does the job but this is a simplified example and actually x and y have
> much more items and the gerund is more complicated as well.
>
> So scanning the complete y for every atom of x does not seem very
efficient.
But that seems to be the essence of what you are doing. In
the general case for each scan step, you are using a different
member from your agenda's gerund for each different atom of x.
With a bit of work you could do this in a single scan, but your
overhead is from the many uses of the agenda which will have
to remain unchanged. If anything pushing everything into a
single scan would make things less efficient since you would
have to iterate over the values of x for each scan element instead
of once per scan.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list