ngn-k-tutorial
ngn-k-tutorial copied to clipboard
Consider describing how K treats whitespace
I was just reading about ':
in more adverbs:
x ': y
WindowSymbol:
':
Args:
int ': array
Note how the syntax is written with a space separating the function/adverb from its args. I didn't pay much attention to this in the past, since I assumed it's just a stylistic thing and that the interpreter wouldn't care about it either way.
This assumption seems right for functions as well as function-adverb pairs where there is no space between the function and adverb:
1-!5
1 0 -1 -2 -3
1 - !5
1 0 -1 -2 -3
1 2 3!'3 4 5
0 0 2
1 2 3 !' 3 4 5
0 0 2
Window is different. I guess syntactically 3 is supposed to take the position of a function, and I guess the interpreter would expect the adverb (if any) to follow immediately, without a space:
3':!5
(0 1 2
1 2 3
2 3 4)
3 ': !5
'nyi
3 ': !5
^
Trying other adverbs with a space also yields interesting results that are difficult to interpret with the information given so far:
-\!5
0 -1 -3 -6 -10
- \!5
0 1 2 3 4
0 -1 -2 -3 -4
+\!5
0 1 3 6 10
+ \!5
0 1 2 3 4
,0 1 2 3 4
2\123
1 1 1 1 0 1 1
2 \123
123
'rank
^
2 \ 123
123
'rank
2 \ 123
^