Since you have an even number of verbs in your train (1 and 2 are parsed as constant 1"_ and 2"_ verbs) the whole is interpreted as a hook, with the leading +/ taking its dyadic form. Your smodd1 verb is (in its monadic form) equivalent to
] +/ 1 + 2 * i. Since you want to apply +/ to the result of the rest of the verb, you can either use @ atop as in +/@(1 + 2 * i.) or [: cap to continue the train but use +/‘s monadic form instead of giving it a left argument: [: +/ 1 + 2 * i. A train is a juxtaposition of an odd number of verbs, the first one being the left argument to the second _unless_ the leading verb is [: . Cheers, Louis > On 15 May 2018, at 10:29, Skip Cave <[email protected]> wrote: > > A simple Quora question wants to know the formula to sum the first n odd > numbers. > > I can write an explicit verb: > > smodd =.3 :'+/1+2*i.y' > > smodd 5 > > 25 > > I want to write a tacit verb: > > smodd1=:+/1+2*i. > > smodd1 5 > > 6 8 10 12 14 > > What am I doing wrong? > > > Skip Cave > Cave Consulting LLC > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
