[comp.lang.apl] "over" and "by"

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

 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)

sam@kalessin.jpl.nasa.gov (Sam Sirlin) (01/14/91)

In article <15160010@hpdmd48.boi.hp.com> rrr@hpdmd48.boi.hp.com (Rudi Rynders) writes:
>
> 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
...
>  
>  but how this it work?
>
To see how they work, I applied the various operators first. For example
   a over b
is
   a u@v&w@x b   for appropriate verbs u-x
which is equivalent to
   u v w (a x b)
or
   ;({.;}.)":(a,b)
which is easy to understand. Applying this idea to by (a little more subtle)
I get
   a by b
equivalt to
   (' ';;a),"_1 b
which is also much easier for me to comprehend. 

Sam Sirlin
Jet Propulsion Laboratory         sam@kalessin.jpl.nasa.gov




Sam Sirlin
Jet Propulsion Laboratory         sam@kalessin.jpl.nasa.gov