HNHacker News
TopNewBestAskShowJobs

chrispsn

1,055 karma · joined July 21, 2017

Sydney, Australia.
submissionscomments
chrispsn··on Arthur Whitney releases an open-source subset of K with MIT license
Click on k, then k.zip.
chrispsn··on Learning K programming: idiom by idiom [pdf]
Adding to RodgerTheGreat's comment: for me, k's power is its rich set of adverbs that are convenient to write.

Notice that aside from reverse (monadic |), all verb symbols in the above code are in most other languages (max as |, min as &, plus as +, minus as -). Adverbs (such as / for reduce and \ for scan-reduce) make the symbols we already have more generally applicable.

I think a language could go a long way with a small set of basic arithmetic symbols alongside a rich set of adverb symbols.

chrispsn··on Array languages vs. the curse of the spreadsheet
Glad to hear it’s memorable!
chrispsn··on K/simple: a tiny K interpreter for educational purposes by Arthur Whitney
Everything I've found that's public is documented here:

https://gist.github.com/chrispsn/da00835bb122c42f429a084df83...

The kparc.com links are down though.

chrispsn··on APLcart – Find your way in APL
https://secwang.github.io/ngnkcart/
chrispsn··on K: We need to talk about group
I think we need some kind of grouping function, but it doesn't have to be the 'generate group indices' function. I'm sure we'll have alternatives available such as `update ... by`.
chrispsn··on K: We need to talk about group
In the Wordle dict example, it would have helped if a type system could tell me I was wrong when I assumed that an indexing miss would generate an empty list.
chrispsn··on K: We need to talk about group
Yep - added a link to some simple examples in the article (below). Throughout the article there are also a few links to executable versions of the code examples.

https://ngn.codeberg.page/k/#eJxdjssKwjAQRffzFddVFyLFoiiFQD8...

chrispsn··on K: We need to talk about group
Good point - added a simple explanation in the article:

Group tells you the places each element occurs in a list. It generates lists of indices.

chrispsn··on K: We need to talk about group
Yep, the comments are the BQN version.
chrispsn··on APL: An Array Oriented Programming Language (2018)
I don't think user-level definitions of custom symbols are that useful, but for what it's worth, you can do it in ngn/k...

    (Π):!/:  / make table
    
    Π[`a   `b
     ( 1    2
       3    4)]
chrispsn··on K – A simple, fast vector programming language
In case you've jumped straight to the comments, here are some intro links. Many of these also appear in ngn/k's readme.

First, direct links to ngn/k in the browser:

- REPL: https://ngn.bitbucket.io/k/#r

- Editor: https://ngn.bitbucket.io/k/

Second, the best one-stop shop for an overview of k6's primitives (both ngn/k and oK are based on k6). https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual....

The best intro examples are in John Earnest's k editor iKe - there's a dropdown at the bottom right. http://johnearnest.github.io/ok/ike/ike.html

ngn/k's editor also has an 'examples' dropdown in its menu.

For an illustration of k's strengths, Razetime's matmul refactoring is brilliant: https://github.com/razetime/ngn-k-tutorial/blob/main/c-think...

Finally, some nice examples of concise k:

  {$[2>#?x;x;,/o'x@&'~:\x<*1?x]}    / Quicksort
  
  (+':,)\~!10                       / Pascal's triangle
  
  {x x}{x{x[x]y}y}                  / Y-combinator
Executable versions of above:

- Quicksort (via Kelas's KCC guide): https://ngn.bitbucket.io/k/#eJwrLLaqVok2slO2r7CusNbRz1evcFBT...

- Pascal (via Richie/Attila): https://ngn.bitbucket.io/k/#eJzT0Fa30tGMqVM0NAAADYMCZg==

- Y-combinator (via ngn): https://ngn.bitbucket.io/k/#eJyLtKquUKiora6oroiuiK2srax14IqM...

chrispsn··on Imperative Thinking and the Making of Sandwiches (2014)
> So what would a general purpose language look like if it took these ideas to heart?

K or LINQ?

chrispsn··on Learning APL
The APL Orchard and The K Tree.

https://chat.stackexchange.com/rooms/52405/the-apl-orchard

https://chat.stackexchange.com/rooms/90748/the-k-tree

chrispsn··on The Tyranny of Spreadsheets
A nice shortcut is Ctrl-Shift-U to toggle single- or multi-line view.
chrispsn··on K: War on Raze
> 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...?

chrispsn··on Benefits of 2D code layouts (2018)
A mini-map is a cool idea! In Excel I often temporarily zoom out to get a big picture view of the program structure.
chrispsn··on Notation as a Tool of Thought
You didn't mention it, so for avoidance of doubt: have you heard of k?

Commercial k variants come with a columnar data store (see Kx's q/kdb+, Shakti's k9).

chrispsn··on Notation as a Tool of Thought
Is it a matter of writing a comprehensive stats library?
chrispsn··on The Accelerating Adoption of Julia
Mesh can do this, somewhat - exceptions in table columns stick out like a sore thumb in the sheet source.

http://mesh-spreadsheet.com

chrispsn··on Decision Table Patterns
Mesh Spreadsheet is explicitly designed to make it easier to view and write decision tables with a projectional editor, while keeping the code as text for storage, version control, etc.

https://twitter.com/meshspreadsheet/status/13043816477064478... http://mesh-spreadsheet.com/ https://twitter.com/meshspreadsheet/status/12527139096409866...

chrispsn··on F (2006)

     `A 0: ("some";"lines";"are";"here");     / write to file A
     `B 0: ("more";"lines";"follow";"here");  / write to file B
     _/ 0:' `A`B                              / read files A, B and find lines of B that are not in A
    more  
    follow
chrispsn··on F (2006)
In k9 it should be:

    A_B
chrispsn··on J Notation as a Tool of Thought
I agree with most of this article, except that - for me - grouping by table columns is a more intuitive and flexible way to control subset application than 'rank'.

k9 is in development, but blending k7 and k9 we'd get something like:

   t: [[]sensor:  1 2 1 2 1 2
         day:     1 1 2 2 1 1
         reading: 1 2 3 4 5 6]
  
   0 1 1 0 * select by sensor, day from t
  sensor day|             
  ------ ---|----------------
  1      1  |[[]reading: 0 0]
  1      2  |[[]reading: ,3]
  2      1  |[[]reading: 2 6]
  2      2  |[[]reading: ,0]
chrispsn··on Luckysheet, an open-source spreadsheet
> you can name columns and use the name in formulas

You can do that in Excel too: whether it's the whole column of a sheet, or a column of a table - syntax for latter is `someTable[someColumnName]`. Mesh will have the latter, albeit with different syntax.

Thank you for the links! I will have a look. There's a deep history.

chrispsn··on Luckysheet, an open-source spreadsheet
Thanks! I have been considering this!

It might impact the 'flow' of modelling eg using automatic cell names like 'A1'. And it might complicate storing the sheet as text (might need to store more complex layout info than 'table is at coordinates x,y').

But it could also make layout easier, eg tables underneath each other could have different column widths. Could use CSS flow layout.

I also hadn't heard of Spreadsheet 2000 - great reference, thanks.

BTW - I think of the Mesh spreadsheet as a canvas, just a 'discrete' one as opposed to continuous. In theory, if the grain is fine enough (eg 1 character width of a monospace font), then you might be able to get the best of both discrete and continuous approaches.

chrispsn··on Luckysheet, an open-source spreadsheet
Yes, that's it.
chrispsn··on Luckysheet, an open-source spreadsheet
When you say 'has the functionality of a spreadsheet but looks nothing like current spreadsheets', what do you mean?

I am working on Mesh Spreadsheet. It gives you a spreadsheet UI that writes code as text. It will likely use k9 as the formula language once it matures, but:

- you can try the JavaScript prototype at this link: http://mesh-spreadsheet.com

- you can see a proof of concept video using k here: https://www.youtube.com/watch?v=CEG9pFNYBCI

chrispsn··on Tamgucalc: A spreadsheet in character mode with Lisp formulas
Yep. JavaScript can also work as a formula language (per the Mesh JS prototype), but APL family languages such as k are much more ergonomic - and 'punchy' - in a spreadsheet context.
chrispsn··on Ode to J
It's probably like k's find (`?`), which gets the indices of the found elements, or else the length of the list (or null, depending on the dialect) if not found:

     "abc"?"caz"
    2 0 3
Page 1 of 4Next →