# @ > @ ;:
is parsed as
(# @ >) @ ;:
This is not obvious. It's buried in the details of the parsing table.
The practical rule is that in a long sequence of modifiers, each
conjunction operates between its single right operand and everything to
its left, as if it were all parenthesized.
Thus, a@b@c@d is parsed as ((a@b)@c)@d
Then, when it's executed, ((a@b)@c)@d executes d first, followed by c,
b, a; so you get right-to-left execution of the verbs.
Conjunctions like u@v determine the rank of the overall verb from the
rank of v. In these focus on what v is, and its rank. The verb u gets
fed the result of v. But what does v operate on? In
#@> 'a';'bc'
The rank of #@> is 0 because the rank of > is 0. That means that the
overall verb (#@>) HAS RANK 0. This verb #@> will not see the entire
argument all at once. Because it has rank 0, each box will be fed into
#@> separately
(in other words, #@> is executed twice). v will only operate on one box
at a time, so u will operate on the contents of one box at a time. Both
u and v will be executed twice, so there are two atoms in the result.
#@:> 'a';'bc'
The rank of #@:> is _, by the definition of @: . So the entire argument
will be fed into #@:> which is thus executed just once.
> then executes on the entire argument. Since > has rank 0, it
executes twice, once on each box, and the two results are joined
together. Then # executes, once, on the table resulting from > .
Dissect can help here. Dissect
#@> 'a';'bc'
Notice that the > verb displays no data. This is because it is
meaningless to ask 'what is the result of >?' > is executed twice, with
two different results. These results are never joined into a single
noun. # is applied to each one independently. If you select a
result-cell of # by clicking on it, dissect will show you the result of
> that contributed to that cell.
Now dissect
#@:> 'a';'bc'
> shows its result, because it was executed on the entire argument and
the results were combined into a single value fed to # . (dissect also
shows you the fill that was added when the results of > were assembled
into a single array)
The difference is more graphic here:
#@> 'a';1 2
Now
#@:> 'a';1 2
This makes the point that it is meaningless to ask 'what is the result
of >?' in #@> . It isn't even legal to execute > on the entire
argument. Yet #@> 'a';1 2 succeeds.
This explains the difference between your cases 1/2 and 4, which is
entirely the difference between u@v and u@:v .
In 6, #@(> @: ;:) the entire argument is fed to (> @: ;:) and thus the
entire result of ;: is fed to > . The entire result of that is fed to # .
A two-verb example would be
#@(>"1) 'a';'bc'
2
#@(>"0) 'a';'bc'
1 2
Do you see why these are different?
Henry Rich
On 1/22/2016 10:55 AM, Brian Schott wrote:
[Sorry, that was a mistake. This is a resend]
#@:>@:;:'a man a plan a canal' NB. 1
6
#@:>@;:'a man a plan a canal' NB. 2
6
#@>@;:'a man a plan a canal' NB. 3
1 3 1 4 1 5
#@>@:;:'a man a plan a canal' NB. 4
1 3 1 4 1 5
#@(>@:;:)'a man a plan a canal' NB. 5
6
#@(>@;:)'a man a plan a canal' NB. 6
6
These examples are hard for me to grok.
Comparing 1 and 2 and 4 suggests that either order is important or that #
is effected and > is not.
Example 6 suggests that parentheses can produce results like @: especially
when compared with 2.
My experience in the past has been especially puzzling when I try to
combine atop with the MIDDLE TINE result of a fork as the following
examples attempt to cover. In these example I use at and atop in the names
to reflect the use of @ and @: ; I use app in the names to reflect the use
of append . These examples especially the comparison between the
application of meanatop and meanatopapp, clarify to me that atop uses the
rank of its predecessor (%
mean i. 3 4
4 5 6 7
meanat =: +/ #@% #
meanat i. 3 4
1 1 1 1
meanatop =: +/ #@:% #
meanatop i. 3 4
4
meanatapp =: +/ #@,@% #
meanatapp i. 3 4
1 1 1 1
meanatopapp =: +/ #@:,@% #
meanatopapp i. 3 4
1 1 1 1
meanatopappparen =: +/ #@(,@%) #
meanatopappparen i. 3 4
1 1 1 1
meanatappparen =: +/ #@:(,@%) #
meanatappparen i. 3 4
4
On Fri, Jan 22, 2016 at 4:50 AM, Linda A Alvord <[email protected]>
wrote:
I think I finally understand the difference!
A=:'a man a plan a canal'
;:A
┌─┬───┬─┬────┬─┬─────┐
│a│man│a│plan│a│canal│
└─┴───┴─┴────┴─┴─────┘
f=: 13 :'#>;:y'
g=: 13 :'#@>;:y'
h=: 13 :'#@:>;:y'
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm