a tacit version
( \:~ ( i. { +/\@:[ % +/@:]) ] ) 1 100 5 10
1 0.862069 0.991379 0.948276
----- Original Message -----
From: Joe Bogner <[email protected]>
To: [email protected]
Cc:
Sent: Tuesday, June 3, 2014 7:32:24 AM
Subject: [Jprogramming] cumulative sum percent
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