The expression for computing the parens nesting level has a storied
history.  (In APL, the expression would have been +\1 ¯1 0['()'⍳c].)  From
A.J. Perlis, *APL is more French than
English<http://www.jsoftware.com/papers/perlis78.htm>
* , 1978:

I was at a meeting in Newcastle, England, where I’d been invited to give a
talk, as had Don Knuth of Stanford, Ken Iverson from IBM, and a few others
as well. I was sitting in the audience sandwiched between two very esteemed
people in computer science and computing — Fritz Bauer, who runs computing
in Bavaria from his headquarters in Munich, and Edsger Dijkstra, who runs
computing all over the world from his headquarters in Holland.

Ken was showing some slides — and one of his slides had something on it
that I was later to learn was an APL one-liner. And he tossed this off as
an example of the expressiveness of the APL notation. I believe the
one-liner was one of the standard ones for indicating the nesting level of
the parentheses in an algebraic expression. But the one-liner was very
short — ten characters, something like that — and having been involved with
programming things like that for a long time and realizing that it took a
reasonable amount of code to do, I looked at it and said, “My God, there
must be something in this language.” Bauer, on my left, didn’t see that.
What he saw or heard was Ken’s remark that APL is an extremely appropriate
language for teaching algebra, and he muttered under his breath to me, in
words I will never forget, “As long as I am alive, APL will never be used
in Munich.” And Dijkstra, who was sitting on my other side, leaned toward
Bauer and said, “Nor in Holland.” The three of us were listening to the
same lecture, but we obviously heard different things.



On Wed, Jun 12, 2013 at 8:22 AM, Roger Hui <[email protected]>wrote:

>    c=: 'comb4=: [ (([ = [: +/"1 ]) ([: |. [: I. #) ]) [: #: [: i. 2 ^ ]'
>
>    +/\ 1 _1 0{~ '()' i. c
> 0 0 0 0 0 0 0 0 0 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2
> 2 2 2 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>
>    c,:1":+/\ 1 _1 0{~ '()' i. c
> comb4=: [ (([ = [: +/"1 ]) ([: |. [: I. #) ]) [: #: [: i. 2 ^ ]
> 000000000012222222222222211222222222222221110000000000000000000
>
> The parens look matched to me.
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to