« first day (1069 days earlier)      last day (466 days later) » 

05:44
@ngn Hi, how did you set up ngn.bitbucket.io/k and how could I embed ngn/k in a webpage?
You can try analyzing the JS in the html file. It may look pretty dense but it's readable because it's all hand-written (except the pako line, which you can copypasta verbatim)
And then upload a copy of k.wasm in your server
At least it's 100x easier than embedding RustPython
 
2 hours later…
08:25
@Bubbler Yeah, I gave up on that and used pyodide. Where is the k.wasm file?
 
2 hours later…
 
5 hours later…
15:21
@scrawl I think that's the magic value
 
1 hour later…
16:24
@coltim completely forgot about the magic value. thanks coltim!
ngn
ngn
@copy side effect from dict,dict returning dict - now it looks like that was a bad idea
So is there no way to make an array of dicts at the moment? Trying to improve a hashtable implementation:
pr:1000003               / prime
s:pr#,()                 / hashtable: positions -> score
h:5/                     / hash
g:{*|*(*'h=)#s@pr!h:h@x} / get
p:{s[pr!h]:(,h,y),s[pr!h:h@x];} / put
ngn
ngn
16:42
@copy i guess not. i'll try to fix it.
actually, dict,dict -> dict should be fine but my append() routine is wrong
What's actually happening in #{(!0)!!0}'100#0? Is # looking into the array or is ' doing something?
ngn
ngn
' starts with an empty list (()) and appends to it 100 times, but for dicts my append uses concatenation (,) and that's incorrect
I see, interesting
ngn
ngn
17:22
@copy hm.. after a bit of investigation, i think the root of the problem here is lack of prototypes
if you change the { } to return a non-empty dict, ' correctly returns a table
if the returned dicts have incompatible keys, the result from ' is correctly decomposed into a list of individual dicts
the only trouble is with empties :/
That works for me
ngn
ngn
i should gather courage and maybe set aside a week or two to attempt implementing prototypes and risk breaking everything :)
I have tests, I don't mind ;-)
ngn
ngn
to illustrate what's going on, this is what enlist (which is the same as appending a dict to ()) does to a dict:
 ,(!2)!!2
+0 1!(,0;,1)
 ,(!1)!!1
+(,0)!,,0
 ,(!0)!!0
+(!0)!!0
note how the values of the last result are a 1d array when they should be a 2d array like in previous results
but there's no way to make a 0-by-1 array in ngn/k at the moment
Right
Is this related?
s:10#,((,0N)!0)
s[0],:(,3)!4
s[0]
0N 3!(0 0N;0N 4)
Expected 0N 3!0 4
Actually, s[0]:s[0],(,3)!4 works
Initialising like this works too: s:{(,x)!x}'!10
Turned out to be quite beautiful (and slightly faster) in the end:
s:{(,x)!0N}'!pr      / hashtable: positions -> score
H:5/
g:{(s@pr!h)@h:H@x}   / get
p:{s[pr!h;h:H@x]:y;} / put
ngn
ngn
18:26
@copy to be honest, i'm not sure what the correct result is there
oh.. you're right, it should be 0N 3!0 4
my amend isn't very advanced :)
@copy interesting - k4 produces a similar result

« first day (1069 days earlier)      last day (466 days later) »