Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!cca!ima!haddock!johnl From: johnl@haddock.UUCP Newsgroups: net.lang Subject: Re: APL myths - (nf) Message-ID: <196@haddock.UUCP> Date: Tue, 26-Jun-84 23:38:21 EDT Article-I.D.: haddock.196 Posted: Tue Jun 26 23:38:21 1984 Date-Received: Sat, 30-Jun-84 02:24:07 EDT Lines: 43 #R:decwrl:-198200:haddock:12300006:000:1625 haddock!johnl Jun 26 11:04:00 1984 I also used to think that APL was unreadable, but discovered that I was going about it the wrong way. APL turns out to be quite readable once you understand how to read it. Certainly, if you try to read an APL program the same way you'd read a C or Fortran program, you'd get quite frustrated. First, it's OK that it takes longer to read a line of APL that it takes to read a line of Fortran, because a line of APL does more than a line of Fortran. Then, you have to read by idioms. In Fortran, you can look at this and tell pretty quickly what it does because you've seen it 1000 times before: xmax = 0 do 100 i = 1, n if(a(i) .gt. xmax) xmax = a(i) 100 continue In APL, an analogous thing would be XMAX gets ceiling / A which is as easy to read. You read larger expressions by recognizing familiar "idioms" (a term coined by A. J. Perlis, who has published long lists of his favorite APL idioms.) For example, "X iota X" is an idiom used in finding or removing duplicates in a vector where the Nth element is N if the corresponding entry in X is different from all the previous ones and less than N if not, and "iota rho X" is the numbers from 1 to the size of X, i.e. the subscripts of all of the entries in X. So: ((iota rho X) = X iota X) / X turns out to be an expression that is X with the duplicates removed. But you look at that, recognize "X iota X" and "iota rho X" as familiar idioms, and you're well on your way to understanding it. After a while you learn to recognize such larger idioms, too. John Levine, ima!johnl PS: I still think that APL's I/O, in whatever version, stinks.