TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

K: War on Raze

79 pointsby chrispsnalmost 4 years ago

4 comments

mlochbaumalmost 4 years ago
Hm, just wrote up an explanation[0] of BQN&#x27;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&#x27;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&#x27;re searching to see what rank they have, and from that determine how to split up the other argument. But BQN&#x2F;J&#x2F;APL and K are different in that the APL group uses multidimensional arrays, giving it a concept of rank (number of dimensions) that&#x27;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&#x27;s understandable you&#x27;d want to avoid it in K.<p>This difference in array models is also part of the reason why Dyalog&#x27;s ⍸ does a &quot;deep where&quot;. In APL it&#x27;s not considered &quot;deep&quot; at all, because the argument is a numeric array; it would be called &quot;high rank&quot;. There&#x27;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&#x27;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&#x27;ll end up with the same inconsistency if you try to combine the two versions.<p>[0] <a href="https:&#x2F;&#x2F;mlochbaum.github.io&#x2F;BQN&#x2F;doc&#x2F;search.html#higher-ranks" rel="nofollow">https:&#x2F;&#x2F;mlochbaum.github.io&#x2F;BQN&#x2F;doc&#x2F;search.html#higher-ranks</a> (in the code examples, &quot;high&quot;≍&quot;rank&quot; couples rows to give the 2x4 shape seen below, and similarly 3‿2⥊4 creates a 3x2 array)<p>[1] <a href="https:&#x2F;&#x2F;aplwiki.com&#x2F;wiki&#x2F;Index" rel="nofollow">https:&#x2F;&#x2F;aplwiki.com&#x2F;wiki&#x2F;Index</a><p>[2] <a href="https:&#x2F;&#x2F;mlochbaum.github.io&#x2F;BQN&#x2F;doc&#x2F;indices.html" rel="nofollow">https:&#x2F;&#x2F;mlochbaum.github.io&#x2F;BQN&#x2F;doc&#x2F;indices.html</a>
评论 #27851967 未加载
评论 #27850590 未加载
RyanHamiltonalmost 4 years ago
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: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;kcodetweets" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;kcodetweets</a> I love it.
marrowgarialmost 4 years ago
Love seeing the random k&#x2F;q code mentions here. All too often I feel as though I&#x27;m coding in a black box. This shines a little light letting me know others are out there too. Nice work.
评论 #27851914 未加载
评论 #27854485 未加载
1vuio0pswjnm7almost 4 years ago
Is there an ngn k equivalent of &quot;hcount&quot; (-7!x)?
评论 #27852398 未加载