y
1 100 5 10
   y,.runsumpct y
  1        1
100 0.862069
  5 0.991379
 10 0.948276

Please provide an English description of the problem being solved.  In
particular, I don't understand how the result is "in the original order".
 In addition, won't you have a problem if the argument has duplicate
entries?

   t,.runsumpct t=: y,1 1 1
  1  0.97479
100 0.840336
  5 0.966387
 10  0.92437
  1  0.97479
  1  0.97479
  1  0.97479





On Tue, Jun 3, 2014 at 4:32 AM, Joe Bogner <[email protected]> wrote:

> Is there a cleaner way to write this or is this a reasonable
> implementation?
>
> runsumpct =: 3 : 0
>
> sorted=: \:~ y
>
> vals =: (+/\ % +/) sorted
>
> (sorted i. y) { vals
>
> )
>
>
> runsumpct 1 100 5 10
>
> 1 0.862069 0.991379 0.948276
>
>
>
> I'm interested if there's a cleaner approach to sorting, operating, and
> then returning the result in the original order.
> ----------------------------------------------------------------------
> 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