New feature in Kap: Subscript index
I was listening to the latest episode of Array Cast which featured Kai Schmidt, the creator of Uiua.
I was listening to the audio version of the episode, so I couldn't follow all the things that were shown on the screen, but I still found the discussion very interesting.
The discussion was about the new release of Uiua, and one of the features that was mentioned was the use of subscript characters. They way it's used in Uiua is very neat. It's used to indicate the arity of a function if the compiler can't deduce it itself.
Anyway, as I was travelling to work, I was thinking about how the subscript characters can be used in Kap, and I realised that they could be used to make function axis indicators much nicer.
So, as I got home I implemented support for this. The idea is simple: Subscripted numbers can be used as an alternative to function axis as well as array indexing. An example will make it more clear: foo[15] can be expressed as foo₁₅.
Enclose over axis 1:
⍝ Instead of: ⊂[1] 3 4 5 ⍴ ⍳24
⊂₁ 3 4 5 6 ⍴ ⍳24
Reduce over axis 3:
foo ← 2 2 2 2 2 2 ⍴ ⍳64
⍝ Instead of +/[3] foo
+/₃ foo
It is also possible to use subscripts when indexing into the major axis of an array:
bar ← 3 3 ⍴ ⍳9
⍝ Same as: bar[1] which is the same as bar[1;]
bar₁
Negative indexes still works:
⍝ Same as bar[¯1]
bar₋₁
Note that this syntax does not replace the existing syntax. It's merely an alternative way to express the same thing if the argument is a single constant number.
In the JVM-based UI as well as the web-based client, these symbols are typed using the prefix key, followed by f and the subscripted character. Currently the values 0 to 9 and minus - are supported.