Hello Mikl;

It seems that you're asserting that:

   NEW -: 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.

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
>
> -- 
> Mikl
> ----------------------------------------------------------------------
> 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