Hi Steven,

The following is based on the equivalent of Dyalog 'each' and may facilitate
further exploration and learning (well, it does for me!)

f=: 3 : 0
y1=. <\|.y
y2=. |. &.> y1
y1 *&.> y2
)
   f  i.5
+--+-----+-----+-------+---------+
|16|12 12|8 9 8|4 6 6 4|0 3 4 3 0|
+--+-----+-----+-------+---------+

Further, we may play some more:

f1=: <\@|.
f2=: |.&.> @ f1
f3=: f1 *&.> f2

f3 i.5
     (f -: f3) i.10
1

The next (interesting) step I guess is the intellectual leap from this very
simplistic solution to R.E. Boss's much more elegant and efficient solution.
This is left as an exercise to the reader. :-)

Enjoy
ken


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven Taylor
Sent: 21 October 2008 12:19
To: [email protected]
Subject: [Jprogramming] How to Infix scan two arrays,and let one be reversed
mid-operation?

Hi,

I'm new to J.  I like what I see so far.

Here is simplified version of the problem I'm trying to solve. 

N =: i.10
M =: |. i.10
< \ (|. N) * M

│81│81 64│81 64 49│81 64 49 36│...│81 64 49 36 25 16 9 4 1 0│

But what I want is actually the reverse of the cumulative window.  Not the
reverse of the entire list N -- only the reverse of N after N is broken into
a segment.

The result I'm trying to get:
|9 * 9|9 * 8 8 * 9|9 * 7 8 * 8 7 * 9|9 * 6 8 * 7 7 * 8 6 * 9|... etc
Which is 
|81|72 72|63 64 63|54 56 56 54|... etc

Thanks,
-Steven

P.S. Sorry about the duplicate email.  I hit ctrl+enter in outlook when I
meant to do this in a different program.

Internal Virus Database is out-of-date.
Checked by AVG. 
Version: 7.5.526 / Virus Database: 270.8.0/1722 - Release Date: 13/10/2008
07:50
 

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

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

Reply via email to