You can do

    (_1 + 2 %~/\ ]) 4 5 3
 0.25 _0.4

which uses Insert / and Infix \ 

--Kip Murray

Sent from my iPad

> On Feb 17, 2014, at 5:30 AM, Joe Bogner <[email protected]> wrote:
> 
> 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

Reply via email to