<:2%~/\i.10 this also does the trick.
Den 12:49 mandag den 17. februar 2014 skrev Bo Jacoby <[email protected]>: ([:<:}.%}:)i.10 >_ 1 0.5 0.333333 0.25 0.2 0.166667 0.142857 0.125 >But you probably do not want the shorter solution, but the more transparent >one. > > > > >Den 12:31 mandag den 17. februar 2014 skrev Joe Bogner <[email protected]>: > >From the J in 5 minutes thread, I'm starting to build my example >> >>In my example, I'm working with stock prices. One of the the outputs is a >>daily % change over the previous day >> >>I want the code to be clean. Is there a cleaner way to express this, or >>would this be considered fine? >> >>I want to calculate % change of y over x >> >>Nums=.i.10 >>pctChange=:3 : '((}. y) % (}: y)) -1' >> >>pctChange Nums >>_ 1 0.5 0.333333 0.25 0.2 0.166667 0.142857 0.125 >> >>pctChange 4 5 3 >>0.25 _0.4 >> >> >>It seemed like I should have been able to do something with Insert, but I >>can't figure it out. >>---------------------------------------------------------------------- >>For information about J forums see http://www.jsoftware.com/forums.htm > >> >> >> >---------------------------------------------------------------------- >For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
