All, but 1 or 2 of https://code.jsoftware.com/wiki/Vocabulary/ModifierTrains are extremely useful. Their use is mainly in creating compound modifiers (expressions that return modifiers) or quick modifiers.
The core "adverbial programming" in J has always been the much simpler adverb sequence train AAA...AA which extends to A(uC)A(Cv)...AA NB. uC and Cv are adverbs resulting from bound conjunctions. Another core J concept to adverbial programming is that of the verb phrase. u1 C1 v1 C2 v2 NB. a verb phrase is a/results in a verb. More generally, fully bound modifier. noun phrase is the same concept. A frequent source of errors in my J career is that the above parses as: (u1 C1 v1) C2 v2 NB. when I could have intended u1 C1 (v1 C2 v2) C1 binds just to v1 instead of the whole verb phrase to its right. The approach I used in myvarp3 is one meant to enhance editability of expressions v1 (u1 C1) C2 v2 NB. original v1 C2 v2 (u1 C1) NB. edit for "intent" The key issue with parentheses is that they are more readable/editable the shorter they are and especially the less nested embedding there is. In above examples u1 v1 v2 can be edited/expanded into longer verb phrases. Constructing (u1 C1) lets you move it as a short block to where it will "best apply". It is fairly easy to recognize it as an adverb. So in a longer expression, where laziness could miss intent. v2 C3 v3 (v1 C2) (u1 C1) NB. much cleaner than: u1 C1 (v1 C2 (v2 C3 v3)) NB. nested mess. Basically the first style allows simpler editing. Even if the intent were u1 C1 (v1 C2 v2) C3 v3 , v2 (v1 C2) (u1 C1) C3 v3 NB. moving a single continuous block of code (from previous section) to achieve new intent. On Wednesday, February 15, 2023 at 07:12:52 a.m. EST, Jan-Pieter Jacobs <janpieter.jac...@gmail.com> wrote: The reason it's hard to find anything else on modifier trains is that they have been removed from the language a long time ago (with j501 in 2002, apparently), and only reintroduced recently with j903. Before the reintroduction, the only modifier trains were bidents: - partially applied conjunctions, yielding adverbs; and - chained adverbs, being applied to their left argument in order. They were left over because they are simple, intuitive and easy to remember (guessing here, as I wasn't around in the J scene yet). These are explained well in https://www.jsoftware.com/help/learning/15.htm . The adverbs each and every defined in the standard library library are useful examples of the first kind of bidents: type&.<'each' adverb each &.> The rabbit hole of general modifier trains is deep: they are not completely intuitive (at least to me) and require a thorough understanding of the parsing and execution in J, especially when chaining more than three. They are also not indispensable, as you can write explicit conjunctions and adverbs to do anything such tacit modifiers would do. I have yet to find a useful, non-trivial purpose for them... Of course, feel free to use them if you like the challenge, but there are far more important areas to get to know in J, like rank. Or all the wonderful labs (in the menu, help > studio > labs). Good luck on your journey! Jan-Pieter Op wo 15 feb. 2023 om 04:36 schreef More Rice <mrmorer...@gmail.com> > 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 > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm