critiques? Yes I know this can be solved with imaginaries, I'm looking for advice on idiomatic K
Really this is just a translation of my APL solution
@ngn some feedback on the help menu. 1. I love the examples. Super helpful, and immediate 2. I still think the original table is useful. 2a. I would make \ display the menu of all options for \, like \w \h \l etc, and keep an option to display the compact table you had originally to get an overview of everything on a tight single screen
``` `c$65 66 67``` casts numbers to characters, and simply doing arithmetic with characters should coerce them to numbers. Monadic $ converts datatypes into charvecs of their display representation
eachright takes a left and right argument and applies them through a dyadic verb. each takes a right argument and applies each element of it through a monadic verb
@nathanrogers for ⎕← i borrowed " \" (that is: space backslash; nothing to do with "scan") from k9. in docs it's described as "trace" - not a good name..
@nathanrogers fixed
@nathanrogers try again pls (after git pull and make)
Wait so every ouput from 0: is a list, and if its one line `*0: file` is sufficient because I'm just getting the first element of the lines as a list of lines. I see
@ngn to increase adoption for ngn/k i suggest: 1. split into main and libk, 2. allow custom implementations for os interface, your syscalls as one example. 3. allow external functions to use k types and assign to k variables (as funcs) no need for built ins, maybe a new native function type. 4. things like http server should be a stand alone implementation using libk (no stdin/out with text). 5. ffi is not necessary anymore.
@nathanrogers if it's simple enough to write a wrapper and compile it into the interpreter, there's no need for ffi. it's only necessary, if you have no source or cannot compile.
@nathanrogers you'd have to do that anyway. external libraries do not know k memory/vector model. you pass a k type and want a k result. so you need a wrapper.
in fact, k doesn't even know the type of variables. So f:{x+y};1 f 2 and f:4;1 f 2 must be parsed & executed exactly the same way (and there's no stranding)
@dzaima (a stranding-like shortcut for numerical arrays exists, i.e. 1 2 3 is a 3-item vector. But that's only for numbers, and even 1 (2) 3 is an error)
some k versions have builtin verbs that are parsed as infix. in some versions you could defined them by assigning them into a special namespace (k-tree directory). ngn does not like it.
@dzaima @nathanrogers ngn/k extends k with single-unicode-char identifiers acting as verbs. @coltim wrote this for golfing purposes, it's automatically \l-ed in the wasm interpreter.
I came up with a couple others - https://ngn.bitbucket.io/k/#eJxdUsty0zAU3fsrFBNaO4mx01IodsiD9/v9TvNQEzVR68iuLSdyCZ6yYQpMt2UGhuExFLas6I4F/ZN8QT+BK6dDZ9hImnPOPffqSDVbrZ07f+HipctXrl67fuPmrdt37t67/+Dho8dPnj5TFWyreLnTJSu9/ipdcwfM89eDkEfDkYg3VIXZqlWcmz+5cOr04hlV0SYv39q6rS4x1UTmqkcZGlHeR4yMXMpIqGh/fkgeqUvI5N4aYXSDKNrBp51fALeRZSPTDyjjiqLt7+n2c3HcOmHl4xfIXHE9zI0uHUoGxMX9PWRSNiRBCA6TzR1byseGAC1eDj034gQNsRul7Hcgs/Vi6VjseHXh5OJGodiKHU2UY31sm5qYifV8ppgHH2HEDfAIMOtNS+20tu0m1ZZwtKrQsxk4ZNo89qUQNtI1OHVhsHdSC6aWboiSBWRIeywawG0mr7/pdlJGpkvC0OB9zAyyHmE3ZdLRq6V09LAjoV0Ql5DZCwjmJPhPvzvVl6W+S6YFn6HgLDKZx9E/3ZYc…
but it's too open ended for me to really flesh it out
\l 2015.k
rlwrap: warning: k crashed, killed by SIGSEGV (core dumped).
rlwrap itself has not crashed, but for transparency,
it will now kill itself with the same signal
\l 2015.k 'rnk {.'"x"\'x} ^ I get other errors when I define s02p:.'"x"\'
its these kinds of unpredictable errors that make me afraid of being clever, I had tried the just using *, and I got weird behavior, so I wrapped in {} and the weirdness abated, so I just default to it
@ngn I commented out the suspicious lines in vim last night, didn't change anything about the behavior. The true culprit is Plugin 'christoomey/vim-tmux-navigator'
if I disable this line, there's no issues, if I don't, ctrl + hjlk gives me a giant screen full error about how something isn't valid input, and args is not defined
I looked for args in that library and didn't see it off hand
if I comment out that plugin I can 1. switch between panes in vim using the hotkeys 2. switch between panes in tmux using the hotkeys
I cannot 3. switch between the panes of vim and tmux if vim is open in 1 tmux pane
so what that plugin allows me to do is seemlessly switch between panes of either seamlessly
but I don't know enough about tmux or vim to implement such behavior
I see the problem here, I forgot an '
' adjacent to " had me blurry-eyed
@coltim good suggestion... how do I know when that sort of thing is necessary?
(×):* 2×3 6 @ngn that's excellent
just like, when do I know when I have f:{...} and something like 0: "file.txt"1 but I can't just f 0:... I need f@0:... how do I know when to use @?
like I defined (⊃):*: because that's what worked in @coltim suggestion from earlier defining * as *:, it worked in that case, but in s021:{...,*x} I tried to use ⊃x but get a value error
@ngn say i have that little testing data structure and function to run tests, but say I'm going to do 2016, 2017, etc ,and I want to move all my tests into a testing file that imports each year, but each year is the same format.
day 1 part 1 solution 1 part 1 s011
so I'll have the same names accross multiple files. How can I "import" and "namespace" these so that they're referenced correctly
and are there any parallels of "exports" from a given file? in order to encapsulate definitions?