"Sherlock, Ric" <[email protected]> writes: > Sorry I got carried away below, but in case the following is useful:
Eh, no worries. It's interesting. Plus, I'm waiting for a fit to finish. > To develop the train of Don's explanation a bit further: > +/"1 ] 1 _1 1 *"1 x^/i.3 > 21 57 > > Given that we are feeding both verbs a row at a time, we can combine > the ( +/ ) and the ( * ) as one operation using the conjunction ( @: ) > 1 _1 1 +/@:*"1 x^/i.3 > 21 57 I should be able to work this out myself, but why does that parse in the right way? Since both " and @: are conjunctions, I would have thought the precedence rules would give +/@:(*"1), rather than (+/@:*)"1 . I can also see the appeal here of having the x^/i.3 rather than the transpose. > If ( p. ) wasn't provided the following might be an alternative: > evalPoly=: ([ +/ .*~ ] ^/ i...@#@[)"1 0 > 1 _1 1 evalPoly x > 21 57 > > Another alternative is given on the wiki page: > http://www.jsoftware.com/jwiki/Phrases/Polynomials > eval=: ([: +`*/ [: }:@, ,"0)"1 0 > 1 _1 1 eval x > 21 57 Both of these look very interesting. Is there any reason to prefer one form over the other? I'm trying to work on my "J style intuition." Thanks, Johann ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
