4 ms·
>Numpy is small? Small might not be the right word. I mainly had broadcasting in mind when I wrote that. >Is there anything missing...? Not sure I'd call AP
by juliangoldsmith 4y ago
>Numpy is small?
Small might not be the right word. I mainly had broadcasting in mind when I wrote that.
>Is there anything missing...?
Not sure I'd call APL esoteric, given it was originally developed at IBM.
My knowledge of both array languages and NumPy is limited, but one thing missing might be partitioning using a mask.
An example of that would be the following snippet of J, from a WIP implementation of MTF encoding:
mask <@(_1&|.)`<;.1 dict
The line noise in the middle partitions dict by mask and uses a cyclic gerund to apply a different function to each partition. The ;.1 is the partition modifier; before it are the two functions separated by a tick. The second function just boxes its argument (due to different sizes). The first function rotates its argument by -1 places and then boxes it
- p1esk 4y agomask <@(_1&|.)`<;.1 dict Honestly, I'd really prefer to unpack that statement into 20 lines of clear code. Not because I'm not familiar with and not used to this syntax: my preference equally applies to similar terse Numpy statements which I can understand (but which are error prone and require mental effort).
- juliangoldsmith 4y agoTacit expressions like that are interesting and very rewarding to write, but I'd agree that it's way too terse. The Iversonian array languages tend to be like that, since they're derived from mathematical notation. (Though I have heard that tacit expressions are pretty much absent from production APL code.) The aspect I find most interesting is the way primitives can be combined to build up functionality. It's closer to a declarative syntax, where the focus is on the end result instead of the steps to get there.