Thank you for taking the time to explain at the level you knew I could digest. It is really helpful - I can now use @ vs @: in very practical ways.
And the bonus ... The myvarp3 is so much more readable I wondered why I never came across such construction. It puzzled me the entire night as to what I'm looking at. In NuVoc, conjunction's behaviour is described with both left and right operands present. I have never seen one of their operands missing in their description (as to what this case they would do). The closest thing I found in the end is this: https://code.jsoftware.com/wiki/Vocabulary/ModifierTrains "A0 A1" (my guess for myvarp3) is just one of many possibilities to construct trains. It is a beautiful discovery. Unfortunately the material written there is too advanced for a Journeyman like me. I couldn't find any J book/pdf that talks about it in a more digestible way ... and the j wiki only has this page. But I'm really excited about this discovery. thank you. Maurice On Sun, Feb 12, 2023 at 6:58 PM 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > All conjunctions including @ bind to their right argument "tightly" > meaning just the one token. > > The left argument of conjunctions/adverbs is the entire verb phrase to the > left of it. > > myvarp1 uses "linear style" even if it is tacit. `[:` has "no binding" > everything to right will execute first, and whatever is to left will wait > until that provides a result before the left of [: "composes" with the > right. > > @:, by the way, is more strictly equivalent to [:/"linear style" by > ensuring that composition occurs on the full result of the "right > expression". (+/@:) will apply to full "result" of the v argument to @: . > The sum of the full result requires @: > > A style that permits shorter parentheses groups with less nesting for > conjunctions meant to operate on a long expression to the right, the way @, > @: do when "emulating linear style" is to turn the conjunction into an > adverb, placing it to the right of the "right expression". so, > > myvarp3 =: (- +/ % #)(*:@)(+/@:) % # > > > > On Sunday, February 12, 2023 at 04:46:35 p.m. EST, More Rice < > mrmorer...@gmail.com> wrote: > > > > > > Masters, > > I understand that there is an excellent reference implementation of varp in > addons/stats/base/univariate.ijs to learn from, but I'm trying to do > exercises to solidify my understanding of using verb trains/hooks, and the > difference when using Atop. > > I've 2 versions of varp. > > #1 below is typical of what some of you do (credit: Bob's "Maximum > Consecutive 1's in J." Excellent video! Thank you. I wish there were more > of these.) - using cap when we want to string monadic verbs sequentially. > No problem there. > > NB. works - using hook/fork/cap > myvarp1 =: # %~ [: +/ [: *: (-+/%#) > > NB. works - using hook/fork/Atop and no cap > myvarp2 =: # %~ +/ @ (*: @ (-+/%#)) > > > #2 above, for some reason, I need an extra pair of parentheses to the right > of the 1st @ for it to work. I don't get why. For example, the following > is broken. > > NB. It gives me a list instead :( > > myvarp_broken =: # %~ +/ @ *: @ (-+/%#) > > > Why are they (the missing parentheses w.r.t. #2) needed? > > > > thank you > Maurice > ---------------------------------------------------------------------- > 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