To phrase it a bit more verbosely:
conjunctions have a long left reach, and a short right one.
That is, if you'd fully parenthesise the phrase:
a@b@c@d
it would result in:
(((a)@b)@c)@d

for your phrase:
(((i.3) & |.)"(0 _) ]) i.3

i.e. the left argument is bound before the right one comes in play. This is
a consequence of J's parsing rules:
https://code.jsoftware.com/wiki/Vocabulary/Parsing#The_Details_of_Parsing

A handy tool to see how parsing works is trace:

load'trace'
   trace '((i.3) & |."(0 _) ]) i.3'
--------------- 8 Paren ------
(
0 _
)
0 _
--------------- 0 Monad ------
i.
3
0 1 2
--------------- 8 Paren ------
(
0 1 2
)
0 1 2
--------------- 4 Conj -------
0 1 2
&
|.
0 1 2&|.
--------------- 4 Conj -------
0 1 2&|.
"
0 _
0 1 2&|."0 _
--------------- 6 Bident -----
0 1 2&|."0 _
]
0 1 2&|."0 _ ]
--------------- 8 Paren ------
(
0 1 2&|."0 _ ]
)
0 1 2&|."0 _ ]
--------------- 1 Monad ------
i.
3
0 1 2
--------------- 0 Monad ------
0 1 2&|."0 _ ]
0 1 2
|length error in do__userlocale, executing dyad 0 1 2&|.
|   t_z=.    (0 1 2&|."0 _])(0 1 2)


It shows you how the left argument of & is bound before the rank is
applied, and how the error is generated when the hook created is applied to
the result of i. 3 (the last one in your sentence).


Jan-Pieter
On Thu, 1 Jun 2023, 03:39 Elijah Stone, <elro...@elronnd.net> wrote:

> need parentheses
>
>     ((i.3) & |."(0 _) ]) i.3
> |length error, executing dyad 0 1 2&|.
> |       ((i.3)&|."(0 _)])i.3
>     ((i.3) & (|."(0 _) ])) i.3
> 0 1 2
> 1 2 0
> 2 0 1
>
> (i.3) & |."(0 _) is ((i.3) & |.)"(0 _)
>
> On Thu, 1 Jun 2023, 'Viktor Grigorov' via Programming wrote:
>
> > Hello,
> >
> > I'm getting 'length error, executing monad (i.x)&|' for
> >    ((i.3) & |."(0 _) ]) i.3
> >
> > but not for
> >    (i.3) ([ |."(0 _) ]) i.3
> >
> > Why is that? Other primitive dyads work in rotate's place. Current nuvoc
> page on rotate has nothing relevant. I well may be be missing something
> obvious.
> > ----------------------------------------------------------------------
> > 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

Reply via email to