[comp.lang.apl] Yet another message from Roger Hui

loc@tmsoft.UUCP (Leigh Clayton) (01/15/91)

>no. 4836625 filed  6.58.22  sat 12 jan 1991
>from hui
>to   loc
>cc   clapl kei
>ref  4835566
>
>Reply to the following msg re "over" and "by":
>
>> From: rrr@hpdmd48.boi.hp.com (Rudi Rynders)
>> Newsgroups: comp.lang.apl
>> Subject: Re:  "over" and "by"
>> Message-ID: <15160010@hpdmd48.boi.hp.com>
>> Date: 10 Jan 91 20:14:02 GMT
>>
>> The  "OVER" and  "BY" constructs mentioned in my previous
>> note are defined as follows:
>>
>>    over =.;@({.;}.)&":@,
>>    by =.(,~"_1' '&;&;)~
>>
>> Using these one can neatly produce the result of the APL
>> outer product function, as in A jot.+ B for instance.
>> It glues the A vector on to the result as the first column
>> as well as displaying the B vector accross the top.
>> The command is:
>>
>>   A by B over A+/B
>>
>> but how this it work?
>>
>> Rudi Rynders (rrr@hpdmd48.boi.com)
>
>"over" and "by" are verbs defined in tutorial frame "Da" distributed
>with J.  They are used to label the result of outer product,
>making an annotated table, as indicated in the tutorial.  Thus:
>      over=.({.;@;}.)&":@,
>      by=.(,~"_1 ' '&;&;)~
>      a=.3 1 4 2
>      b=.4 2 8 5 7
>      a */b
>   12 6 24 15 21
>    4 2  8  5  7
>   16 8 32 20 28
>    8 4 16 10 14
>      a by b over a */b
>   +-+-------------+
>   ? ? 4 2  8  5  7?
>   +-+-------------+
>   ?3?12 6 24 15 21?
>   ?1? 4 2  8  5  7?
>   ?4?16 8 32 20 28?
>   ?2? 8 4 16 10 14?
>   +-+-------------+
>
>(Note a:  Rynders transcribed "over" incorrectly.  Note b:
>The box drawing chars look better than this on the PC.  Here, I use
>standard ASCII chars to avoid problems in mail transmission.)
>
>The question is, how does this work?  Probably, a reader new to the
>language would start on easier verbs than these.  KEI was the original
>author, and I'd guess that it took even him at least 5 minutes to write
>these verbs...  But, since the question is asked, here's how I'd try to
>get a handle on them:
>
>(0) As always, a good start in understanding a verb is to experiment
>with it.  Try it on various arguments.
>
>(1) If a verb is primitive, try looking it up in the Dictionary.
>The Dictionary may be terse, but it is written carefully, and
>rewards (and requires?) careful reading.
>
>(2) If a verb is non-primitive, decompose it into smaller objects.
>In doing this, I find it helpful to look at the display of a verb.
>For example, "over" looks like this:
>      over
>   +----------------------+-+-+
>   ?+---------------+-+--+?@?,?
>   ??+--+-------+--+?&?":?? ? ?
>   ???{.?+-+-+-+?}.?? ?  ?? ? ?
>   ???  ??;?@?;??  ?? ?  ?? ? ?
>   ???  ?+-+-+-+?  ?? ?  ?? ? ?
>   ??+--+-------+--+? ?  ?? ? ?
>   ?+---------------+-+--+? ? ?
>   +----------------------+-+-+
>
>Some facts one can deduce about verb displays:
>(a) At each level of nesting, there are 1, 2, or 3 boxes.
>(b) A 1-box display is a primitive.  (Try entering ";" or "}." by itself.)
>(c) A 2-box display is either a verb derived from an adverb,
>if the second box is an adverb; or an instance of the hook phrasal
>form, if not.
>(d) A 3-box display is either a verb derived from a conjunction, if the
>second box is a conjunction; or an instance of the fork phrasal form,
>if not.
>
>I recommend entering various verbs and looking at their displays
>to get a feel for them, starting from very simple cases.  Here is a
>set of 24 exercises to get you started:
>  +        +/        +/\
>  +.       +./       +./\
>  +&*      +.&*      *&+.
>  +/&*     *&+/      *&(+/)
>  +%       +%/       (+%)/
>  +,-      -,+       +;-
>  +/,-     (+/),-    (+/,-)
>  -,+/     (-,+)/    -,(+/)
>(Some of these verbs don't do anything useful.  The object is to
>see how verbs combine.)
>
>The display of "over" tells you that it is of the form
>   f2   =. ;  @  ;
>   f1   =. {: f2 }:
>   f0   =. f1 &  ":
>   over =. f0 @  ,
>Having these parts in hand, recursively apply steps (0), (1), and (2).
>

-----------------------------------------------------------
loc@tmsoft.UUCP   (Leigh Clayton)   uunet!mnetor!tmsoft!loc

rrr@hpdmd48.boi.hp.com (Rudi Rynders) (01/18/91)

 Well , this is very interesting ! The definition of "over" I quoted in
 my original query , I did NOT transcribe incorrectly ! It came straight
 from lesson 5 of "TANGIBLE MATH". The "over" mentioned in the previous
 response is different from this. To reiterate:

 As listed in my copy of "TANGIBLE MATH ": over=.;@({.;}.)&":@,
 whereas in the previous response        : over=.({.;@;}.)&":@,

 They both seem to be legal because they achieve the same result.

 My thanks to Sam Sirlin and Leigh Clayton and Roger Hui, for their
 responses.

 One further comment on the issue of whether the "Dictionary" is
 "obscure" or merely "terse". I'll settle for " a bit abstruse".
 It definitely requires some careful study .

 As for my suggestion of a text comparing APL and J: I still
 think it would be a good idea to have one to make the path to "J"
 a bit less thorny. The chances of "J" becoming popular will be a
 lot better with it than without it IMHO.