Hi Thomas, apologies for the length here, but you have asked a good question.

The operation to compose one verb with another is known as “atop” (as defined 
on Pages 12 and 17 in the Arithmetic paper you are reading)… (this is called 
function composition in linear algebra).

In 2002 I believe this was implemented as “f@g” with infinite rank, but in 2019 
is now implemented as “f@:g” and  “f@g” produces a different result now (which 
is what you observed).  I’ll try to explain briefly here.

Using current J please note the 2 differences in your expression below:
   3 (i.&1@<) i.7
1 1 1 1 0 0 0
   3 (i.&1@:<) i.7
4

In 2002 (I believe that) @ produced the 2nd result, but now it behaves 
differently.
This change was required to deal with how “verb rank” impacted on “verb 
composition”.

To the heart of your question: B2 was to encourage you to find the index of the 
first item where the left argument is < the right argument, for which the 
process is:
   3 < i.7
0 0 0 0 1 1 1
   (i.&1)3 < i.7.    NB. Find the first 1 in the result
4

All good here, so using “verb composition” to combine the 2 verbs as a new 
“derived verb”, and using current J, we now see:
   cl =: i.&1@<
   3 cl i.7
1 1 1 1 0 0 0

But what happened ?    This does not match the result above of 4 ??
It is because the “Rank of <“ (a scalar, or rank 0, function) now causes the 
derived function cl to work on each item.
So it actually produced the following result:
   3 < i.7
0 0 0 0 1 1 1
   0 0 0 0 1 1 1 (i."0)1.    NB. Here I am applying i. to work on each item by 
forcing it to process “rank 0” (item wise)...
1 1 1 1 0 0 0
   0 i. 1     NB. We can see the individual results here
1
   1 i. 1
0

In order for the derived function cl to use the whole of its argument (ie we 
call this infinite rank), then @: is now used:
   cli =: i.&1@:<
   3 cli i.7
4

If you view the Vocabulary in your current J implementation and look at the 
pages for:
@ and @: you will see the distinction in the “verb rank” defined (@ inherits 
the ranks of g (mv lv rv) and @: is _ _ _ meaning infinite rank, so it applies 
the derived function to the whole argument).

I hope I have clearly explained the distinction but you can experiment further 
to see how “verb rank” mixes with @ and @: here:

   box=:<             NB. A “box” function to box the argument it sees ...
   3 box@< i.7.   NB. Note here that ‘box’ is given each item as it is processed
┌─┬─┬─┬─┬─┬─┬─┐
│0│0│0│0│1│1│1│
└─┴─┴─┴─┴─┴─┴─┘
   3 box@:< i.7    NB. Note here that ‘box’ sees all 7 items at once
┌─────────────┐
│0 0 0 0 1 1 1│
└─────────────┘

Perhaps Henry, Roger or others can confirm or correct me on the very early 
behaviour of @, my recollection is a bit rusty, but I believe it was initially 
implemented with infinite rank.
Notwithstanding, the explanation above will help you to understand exactly how 
it is now implemented.

HTH, Rob H


> On 6 May 2019, at 5:41 am, Thomas Bulka <thomas.bu...@posteo.de> wrote:
> 
> Am 05.05.2019 20:52 schrieb Roger Hui:
>> When applied dyadically, the verb finds the index of the first place where
>> x is less than y
>> The verb is not very meaningful when applied monadically.
> 
> Hello Roger,
> 
> thank you very much for your quick reply. I think I got it now. But, just a 
> follow-up question, to consolidate my understanding: cl is defined with @ and 
> is thus subsequently applied to all members of y:
> 
> cl =: i.&1@<
> 
> 3 cl i.7 --> 1 1 1 1 0 0 0
> 
> That means, cl is semantically equivalent to 3 (<:~) i.7 - or is there any 
> difference?
> 
> Thanks again and best regards,
> 
> Thomas
> 
> ----------------------------------------------------------------------
> 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