Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!darwin.sura.net!haven.umd.edu!socrates!socrates!rockwell
From: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Subject: Re: Symbol Choices in J and APL/!
In-Reply-To: wchang@primate.cshl.org's message of Thu, 26 Mar 92 09:06:58 GMT
Message-ID: <ROCKWELL.92Mar26091356@socrates.umd.edu>
Sender: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Organization: Traveller
References: <1992Mar26.090658.12413@cshl.org>
Date: Thu, 26 Mar 1992 14:13:56 GMT
Lines: 78

Bill Chang:
   (4) fork and hook and atop and with

   What are fork and hook in the general case under ambivalence?)  I
   am surprised that Iverson chose to use symbols for the conceptually
   simple atop and with, instead of the more difficult fork and hook.
   Any ideas?

Fork combines three verbs.  ATop and With only combine two verbs.  To
get an idea of how complex for would be if, for example, ATop were
taken as the meaning of a string of naked functions, try out this
example:
   vowel  (+. f:)   (space  (*. f:)  (1&shift digit))

in place of the current form:
   vowel  +.  space  *.  1&shift @digit

Hmm.. actually, that particular example doesn't look too bad.  [I hope
it's obvious that the (op f:) notation indicates fork?]


As for meaning under ambivalence, here's the complete list:
x and y are nouns, f g and h are verbs

forks
   x (f g h) y          <-->            (x f y) g (x h y)
     (f g h) y          <-->              (f y) g   (h y)

hooks
   x (f g)   y          <-->             x f (g y)
     (f g)   y          <-->             y f (g y)

   Not all fonts look alike (for example vertical placement of tilde
   ~), but these primitives occur so often they really ought to look
   good (at least not distracting).  How does one recognize an idiom
   when it contains so many different styles of symbols?

It takes a little practice.  But so did recognizing APL idioms.

Anyways, complain to the typographers, and the people who declare
character set standards.  Maybe they'll do something about it.

   McIntyre's paper contains a fascinating note written by Ken Iverson
   on the subject of the expand function, which isn't a primitive in
   J.

Actually, Ken Iverson's definition was for the more general 'mesh'
operation.  It can be used in the place of expand, but expand itself
is somewhat less general.  If I wanted to define 'expand' as an
operation, I'd probably have gone about it like this:

If I have a couple utilities:
 where     =.  #  i.@#                  NB. convert bit vector to indice
 shift_1   =.  _1 & (|.!._1)            NB. for finding first difference

Then, 
 exp expand sequence

is equivalent to:
 0   (where 0=exp) }   sequence #~ (-  shift_1)@where exp

Which is somewhat complicated, I'll admit.  But for extremely large
arrays, it should be somewhat faster than mesh -- time is O(n) rather
than O(n * log n).  [Assuming /:\: on a boolean hasn't been optimized,
that is.]

But I think that the main point is that expand has mostly been used in
ways that have simpler equivalents.  For example, the APL expression:

 exp expand  exp compress sequence

Is equivalent to 
 0  (where exp) } sequence

Or, you can replace 0 with ' ' if you're dealing with character
arrays.


