Newsgroups:   comp.lang.apl
Path: utzoo!censor!geac!itcyyz!yrloc!intern
From:         loc@tmsoft.UUCP (Leigh Clayton)
Subject:      Yet another message from Roger Hui
Message-ID: <1991Jan14.210146.28858@yrloc.ipsa.reuter.COM>
Sender: intern@yrloc.ipsa.reuter.COM (Intern via QUADRAM)
X-Telephone:  +1 (416) 364-5361 Fax +1 (416) 364-2910 Telex 0622259
Organization: Reuter:file Ltd.
X-Mail:       1900/2 First Canadian Place, Toronto, Canada, M5X 1E3
Date:         14 Jan 91 17:58:07 UT


>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
