From: Jaypee Date: 2005-07-27T23:51:00+09:00 Subject: Re: APL on Acanthae (was Re: Lisp on Lines) Devin Mullins wrote: > Daniel Brockman wrote: > >> Ah. In light of this thread, I'm actually a little curious >> about what other insights one might get from learning APL. >> >> > Not much, I don't think. It's a language whose primary use is processing > lists and matrices of numbers, and whose sole focus is absolute > terseness at the expense of readability in any sense of the word. But > hey, maybe I'm being pessimistic. I shouldn't prevent you from a > potential learning experience: .... Choosing a comment of Dijkstra on APL is as valid having the creator of COBOL comment on Ruby. It's just irrelevant. The terseness of of APL is only a reflection seen from outside. In fact there are many idioms, that you quickly recognize and don't need to spell out. It does give you some different ways to solve a problem, because of the richness of operators. For example as sorting is one of those operators, sorting is easily used as part of an instruction, amongst other operations. I have spent the first 4 years of my professional life coding in APL. The scars are benigne, not as bad as the same amount of Visual Basic. Example: Imagine you had to emulate an old time text processor to justify lines to a given width, by adding spaces where there are already. The width is w (line iota ' ') yields a vector of indices of white spaces in the line (it's the dyadic iota: A iota B) (rho line) is the length of the line (monadic rho) iota n is the vector 1..n (monadic iota) Let's make a vector of all indices of the line : iota rho line Let's reuse as many indices of white spaces as needed: (w - rho line) rho line itota ' ' The dyadic rho is used here, (size rho pattern), it reuses the pattern as many time as needed to fill the result to the specified size. Let's sort all the indices: sort (iota rho line), (w - rho line) rho line itota ' ' Then use the resulting vector with the original line so: line[sort (iota rho line), (w - rho line) rho line itota ' '] is the answer of the problem ... Sorry for the length and OT twist of that reply ;-) J-P