Hello Mikl;

Hello,Randy!

It seems that you're asserting that:

   NEW -: foo OLD

Yes you are right. But more exactly I assert:
NEW -: pat foo OLD

I would agree, and can see what foo would be, if

   NEW =: 0 1 2 3 7 8 10 11 12 13 17 18

but I don't see how you get the NEW you do get.
I dont't need values from OLD in result. I need their indexes in your vector. And for removed items I want it to have indexes of next begger value in your vector. It can be calculated from your vector.

RNEW =: 0 1 2 3 7 8 10 11 12 13 17 18
RIXS =: 0 1 2 3 4 5 6  7  8  9  10 11

Now it easy to see how NEW is calculated
OLD: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
IXS: 0 1 2 3 x x x 4 5 x 6  7  8  9  x  x  x  10 11 x
NEW: 0 1 2 3 4 4 4 4 5 6 6  7  8  9  10 10 10 10 11 12

But I can't use vector because indexes is values in diapason from 0 to 3e9. So I'm looking for numeral algorithm without making intermediate vectors. In other words I need function that can calculate NEW for 3e9
pat foo 3e9 -: ???

--
Mikl


Please tell me what my mistake is.

------------------------------------------------------------------------
|\/| Randy A MacDonald   | APL: If you can say it, it's done.. (ram)
|/\| [EMAIL PROTECTED]  |
|\ |                     |If you cannot describe what you are doing
BSc(Math) UNBF'83        ?as a process, you don't know what you're doing.
Sapere Aude              |     - W. E. Deming
Natural Born APL'er      | Demo website: http://156.34.69.76/
-----------------------------------------------------(INTP)----{ gnat }-

----- Original Message -----
From: "Mikl Kurkov" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, June 11, 2006 4:21 PM
Subject: [Jprogramming] Index converter


I have task for which I couldn't find a solution.

Suppose we have some indexes which relate to some data.
Now I have vector which describe which indexes to keep and which to
remove.

For example:  pat =: 4 _3 2 _1

Positive value - tell how many indexes to keep, negative to remove. So the
pat is telling that I need to keep 4 first indexes then remove 3 next,
keep another 2, remove 1, keep 4, remove 3 and so on.
I need function that for giving index give me new index after applying
such pattern. Indexes of removed items - is index of next keeped item.

So applying this function to i.20 and pat I should see:
OLD: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
NEW: 0 1 2 3 4 4 4 4 5 6 6  7  8  9  10 10 10 10 11 12

Another function will make inverse calculation - for each value from NEW
give the biggest value from OLD.

I wonder is it posible to achieve whithout precalculating vector of NEW
indexes, just by calculating new value from given pat and old index?

Thanks in advance,
Mikl
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to