zlacker

[return to "Notation as a Tool of Thought"]
1. azhenl+m[view] [source] 2020-11-30 00:41:48
>>mafaa+(OP)
This is Kenneth Iverson's 1979 Turing Award lecture.
◧◩
2. blulul+Fa[view] [source] 2020-11-30 02:36:59
>>azhenl+m
Yes. There are some deep insights in this exposition. The irony is (in my opinion) APL is the worst Array/Matrix based programming language. In fairness it was also the first, but compared to Matlab or Julia it is not as expressive and feels much harder to use.
◧◩◪
3. patrec+PA[view] [source] 2020-11-30 08:35:16
>>blulul+Fa
If you think APL is less expressive than Matlab, you probably haven't really grasped it, IMO. Having said that, Matlab is optimized for manipulating matrices and replicating the notation of normal linear algebra and has excellent implementations of basically any numerical algorithm that frequently comes up in this . So writing something like chol(X'*X+diag(eig(X))) in an APL will look uglier and quite possibly slower and less accurate and depending on the numerical routines you need, require extra implementation work on your part.

But that overhead is constant factor, more or less anything you can express well in matlab can be expressed straightforwardly in APL, too, if you have the right numerical routines. That's not true in the other direction though: there's a lot of stuff in APL you cannot express adequately in matlab at all. For example J (and these days Dyalog as well IIRC) have an operation called under which basically does this: u(f,g) = x => f^-1(g(f(x)). So you can write geometric_mean = u(mean, log).

It is completely impossible to implement something like "under" in matlab. Admittedly the J implementation at least of deriving a generalized inverse for an arbitrary function f is a somewhat ill-defined hack, but this is still something that is both conceptually and practically quite powerful. Also, whilst Matlab is really clunky for anything that is not a 2D array and hardcodes matrix multiplication as the one inner-product, APL has more powerful abstractions for manipulating arbitrary rank arrays and a more general concept of inner products.

Also, APL has some really dumb but cherished-by-the-community ideas that make the language less expressive and much more awkward to learn, e.g. the idea of replicating the terrible defect of normal mathematical notation where - is overloaded for negation and subtraction to every other function.

◧◩◪◨
4. moonch+QE[view] [source] 2020-11-30 09:20:36
>>patrec+PA
> Admittedly the J implementation at least of deriving a generalized inverse for an arbitrary function f is a somewhat ill-defined hack

Have you seen the version used by dzaima/apl[1]? The equivalent of '(-&.:{:) i.5' works and results in 0 1 2 3 _4.

> APL has some really dumb but cherished-by-the-community ideas that make the language less expressive and much more awkward to learn, e.g. the idea of replicating the terrible defect of normal mathematical notation where - is overloaded for negation and subtraction to every other function

Klong[2] is a partial attempt to resolve this. I won't repeat the arguments in favour of ambivalent functions, as I guess you've heard them a dozen times before

> u(f,g) = x => f^-1(g(f(x)).

Other way round; it's g^-1(f(g(x)))

1. https://github.com/dzaima/apl

2. https://t3x.org/klong/

◧◩◪◨⬒
5. patrec+Ha2[view] [source] 2020-11-30 19:34:56
>>moonch+QE
Is there an argument for ambivalent function definitions other than "keyword" recycling (possibly in a mnemonic fashion)?

I hadn't seen Dzaima's APL, thanks! I like that he made a processing binding; APL always seemed like it would be such an obvious choice for doing dweet style graphics code golfing that I wondered why no one seemed to be doing it. A web-based APL would be a better choice though.

◧◩◪◨⬒⬓
6. moonch+9d2[view] [source] 2020-11-30 19:47:52
>>patrec+Ha2
> web-based

In that case you'll be wanting ngn/apl[1], which runs in a browser and compiles to js.

> ambivalent

The arguments are mostly linguistic. Natural language is also context-sensitive, so we are well-equipped to parse such formations; and they allow us to reuse information. The monadic and dyadic forms of '-' are related, so it's less cognitive overhead to recognize its meaning.

1. https://gitlab.com/n9n/apl

[go to top]