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

Reply via email to