[HN Gopher] K: War on Raze
___________________________________________________________________
K: War on Raze
Author : chrispsn
Score : 30 points
Date : 2021-07-15 08:29 UTC (14 hours ago)
(HTM) web link (gist.github.com)
(TXT) w3m dump (gist.github.com)
| mlochbaum wrote:
| Hm, just wrote up an explanation[0] of BQN's high-rank searching,
| which is the same concept used in J and APL and turns into rank-
| sensitive search in K. The issue it addresses is that in array
| programming you'd like to search for each of an array of elements
| all at once, but this is hard to distinguish from just searching
| for the array itself. So you look at the entries of the array
| you're searching to see what rank they have, and from that
| determine how to split up the other argument. But BQN/J/APL and K
| are different in that the APL group uses multidimensional arrays,
| giving it a concept of rank (number of dimensions) that's
| separate from array nesting. K uses only 1-dimensional lists, and
| it considers the rank to be the level of nesting. With respect to
| rank-sensitive search this is kind of precarious. You might think
| of a structure as a list of lists, but will K interpret it as a
| matrix? So it's understandable you'd want to avoid it in K.
|
| This difference in array models is also part of the reason why
| Dyalog's [?] does a "deep where". In APL it's not considered
| "deep" at all, because the argument is a numeric array; it would
| be called "high rank". There's still a problem with this version
| though, because the high-rank version of [?] needs each index[1]
| to be a list, but the normal version (when the argument is
| 1-dimensional) uses one number for an index. The results of [?]
| for different rank arguments are actually inconsistent. In BQN, I
| decided Where should just be restricted to the 1-dimensional
| case. I wrote a little more about the kinds of array indices at
| [2]. It's worth noting that K has this problem a lot less than
| APL, because most of the time you will only index into a single
| dimension. But with constructs like deep where these problems
| appear in K as well, and you'll end up with the same
| inconsistency if you try to combine the two versions.
|
| [0] https://mlochbaum.github.io/BQN/doc/search.html#higher-ranks
| (in the code examples, "high"[?]"rank" couples rows to give the
| 2x4 shape seen below, and similarly 3_24 creates a 3x2 array)
|
| [1] https://aplwiki.com/wiki/Index
|
| [2] https://mlochbaum.github.io/BQN/doc/indices.html
| chrispsn wrote:
| > The results of [?] for different rank arguments are actually
| inconsistent.
|
| Yep. For this reason deep where ideally wouldn't live on '&'.
| It should be able to absorb any structure for subsequent use
| with deep indexing etc, regardless of rank. Perhaps another
| reason to make 'explode' an adverb...?
| RyanHamilton wrote:
| The authors tweets describe the kind of manical pinnacle of short
| perfection that can only be achieved after 5 x 13 hour days of
| solid coding to produce an epiphany that it can all be replaced
| with 1 line or in the case of K, 10 characters:
| https://twitter.com/kcodetweets I love it.
___________________________________________________________________
(page generated 2021-07-15 23:01 UTC)