Does this help?

   require'trace'
   ] sentence=: '% 1 :('':'';''x u /y'')'
% 1 :(':';'x u /y')
   trace sentence
 --------------- 2 Dyad -------
 ':'
 ;
 'x u /y'
 ┌─┬──────┐
 │:│x u /y│
 └─┴──────┘
 --------------- 8 Paren ------
 (
 ':';'x u /y'
 )
 ┌─┬──────┐
 │:│x u /y│
 └─┴──────┘
 --------------- 4 Conj -------
 1
  :
 ':';'x u /y'
 1 : (':'; 'x u /y')
 --------------- 3 Adverb -----
 %
 1 : (':'; 'x u /y')
 % (1 : (':'; 'x u /y'))
 ==============================

Remember that in a trace the ------ line describes the parsing rule
being used (described in appendix E of the dictionary --
http://www.jsoftware.com/help/dictionary/dicte.htm) and subsequent
lines correspond to the bolded syntactic elements which appear in the
table at the bottom of that page. And, finally, the result of
combining those elements is displayed. There is not a lot going on,
here, because we are just building and saving a definition. But it
might help to see the steps performed by the parser?

If the above detail is not helpful, let's try it this way - f and F
behave the same way:

f=: 1 :(':';'x u /y')

F=: 1 : 0
:
   x u /y
)

Remember that in J a sentence is roughly the same thing as a line. In
the definition of F, we see a couple lines which are not sentences but
instead are something else - this is old school computing style. The
isolated right parenthesis signifies the end of the explicit
definition. Meanwhile the isolated colon separates the monadic
definition from the dyadic definition (which one gets used depends on
the context that % f or % F appears in - but since the monadic
definition is empty, using it would always give an error).

   (i.3) % f (i:3)
        0    0  0 0 0   0        0
_0.333333 _0.5 _1 _ 1 0.5 0.333333
_0.666667   _1 _2 _ 2   1 0.666667

   (i.3) % F (i:3)
        0    0  0 0 0   0        0
_0.333333 _0.5 _1 _ 1 0.5 0.333333
_0.666667   _1 _2 _ 2   1 0.666667

Does this make sense?

If not, can you give us a question which helps clarify the confusing issue?

(Please do not worry about appearing ignorant - ignorant people are
the only ones capable of learning. So I'm not learning much of
anything in this message though I learn from messages you all post.
Also, concepts related to definitions sometimes feel slippery for some
people until they work through a bunch of examples for themselves and
maybe even sleep on it a few times. But questions can be better.)

Thanks,

-- 
Raul


On Sun, Dec 8, 2013 at 8:23 AM, Brian Schott <[email protected]> wrote:
> Linda,
>
> I am going to take a stab at answering your question, just to see if I am
> right, assuming others will correct me.
>
> I believe : is a conjunction and thus tries to take as many left arguments
> as it can before executing. In this case the right-most : needs to execute
> before the left-most one is executed, but if the right-most receives
> another operator before it executes, it tries to incorporate that new
> conjunction first. So the parens or your assignment to A force the order
> needed.
>
>
>
> On Sun, Dec 8, 2013 at 3:52 AM, Linda Alvord <[email protected]>wrote:
>
>> Raul,  Here's what you wrote.  I didn't understand the parentheses.
>>
>>    a=:%
>>    l=:i.3
>>    t=:i:3
>>
>>    f=: 1 :(':';'x u /y')
>>    l a f t
>>         0    0  0 0 0   0        0
>> _0.333333 _0.5 _1 _ 1 0.5 0.333333
>> _0.666667   _1 _2 _ 2   1 0.666667
>>
>> So I wrote function which also works and I also don't understand it.
>>
>>
>>    g=: 1 :A=:':';'x u /y'
>>    l a g t
>>         0    0  0 0 0   0        0
>> _0.333333 _0.5 _1 _ 1 0.5 0.333333
>> _0.666667   _1 _2 _ 2   1 0.666667
>>
>>
>> If I remove   A=:  it no longer works!  What is happening here to make g
>> work correctly AND h fail?
>>
>>
> --
> (B=)
> ----------------------------------------------------------------------
> 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