On Wed, Apr 28, 2010 at 11:59 PM, Randy MacDonald <[email protected]>wrote:
> Something I have not seen in the responses, which uses forks, is:
>
> A =: 0&{
> B =: 1&{
> C =: 2&{
> D =: 3&{
>
>
You could remove the duplication(DRY -- Don't Repeat Yourself):
takeverbs=. [: <"1 [: '&'&(,&<)"1 [: ;"1&'{' '0' ;"0 i.
'`a b c d e'=.takeverbs 5
a
0&{
b
1&{
c
2&{
d
3&{
e
4&{
I would appreciate simpler and more intuitive versions of takeverbs though.
(if only there was amend for nested boxes, I could've used a template gerund
and replace the place holder with indices to generate gerunds)
> leading to:
>
> ExpectedVolatility =: (A+B)*C+D NB. usage: ExpectedVolatility data
>
> being the J-esque solution.
>
>
>
> Joe Bohart wrote:
> > Hi All,
> >
> > Been learning J for a bout a year now and very impressed - although it's
> a
> > mind bend. I feel my understanding of complex problem is clearer however
> i
> > have yet to actual code something interesting in J.
> >
> > Here is an interesting problem that I'd like some input on......
> >
> > I'm trying to implement an Expected Volatility equation 4.20 from the
> book
> > (by the Olson group) High Frequency Finance
> > in J and I'm curious if this is the correct J-way of solving a simplified
> > subset of the problem:
> >
> > ExpectedVolatility = (A + B) * C + D
> >
> > so super simple problem reduction:
> > data =: 1 2 3 4
> > goal (non j notation): (1+2)*3 + 4
> > 1st-cut: (0{data + 1{data) * 2{data + 3{data
> > 2nd-cut: +/ 0 1 & { data * 2{data + 3{data
> > 3rd-cut: I'm sure there is a more elegent way to do this, maybe using
> forks
> > ????
> >
> > I'm curious if the following is the correct way to go about solving
> problems
> > in a J-way:
> > The actuality data matrix would be something like:
> > (datetime,px,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
> >
> > I need a verb to transform this noun
> > (datetime,px,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
> > into this (easy to digest noun)
> > (A B C D)
> > where i have not defined the relation,
> > then I'd need another verb to transform the easy to digest noun into the
> > Expected Volatility noun where i have defined the relation above (but
> > probably not in an elegant j-way).
> >
> > Am i on the right path for thinking in J, thoughts, comments...greatly
> > appreciated.
> >
> > Thanks,
> > Joe
> > ----------------------------------------------------------------------
> > 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