« first day (686 days earlier)      last day (849 days later) » 

07:06
@coltim in k9, ? flips dict domain and range
Like find but on the entire data structure instead of specific elements
 
3 hours later…
ngn
ngn
10:31
@coltim how would =`a`b`c!0 1 0 work?
@coltim _sym may be suitable for "delete global variable" too. both are rare.
@chrispsn flips as in swaps them? why would anyone..
 
2 hours later…
12:25
@ngn if calcualted correctly, 25kB are only field names longer that 2 chars. some are keywords.. does minification fail because that would change the interface? maybe it could still be done with a test case run in a loop by renaming each of the symbols.
sum times len symbol
216 36 6 gzhead
222 37 6 window
230 23 10 Uint8Array
240 24 10 windowBits
240 80 3 new
264 24 11 pending_buf
300 75 4 mode
301 43 7 pending
318 106 3 for
324 54 6 length
325 65 5 const
360 30 12 match_length
398 199 2 if
441 49 9 avail_out
465 93 5 break
477 53 9 lookahead
552 92 6 return
568 71 8 strstart
796 199 4 this
12:39
@ngn it comes up a fair bit! For example take targets key intersection for dicts so swap can help target values
 
2 hours later…
14:21
@chrispsn interesting. I was a bit surprised that ?: generally isn't implemented on dicts
@ngn I must be going crazy, I thought I saw things like =0 1 2 3 4!"abcda" returning "abcda"!(,0;,1;,2;,3;,4) (which struck me as a bit weird)
@ngn yeh so far the only real usecase I've come across for _sym lowercasing stuff is doing type-specific stuff where `c~_@x is a bit nicer than |/`c`C=@x
 
2 hours later…
ngn
ngn
16:11
@coltim i might have broken stuff while i was playing with "find". i still don't know what to do with rank-sensitivity
@coltim ok, done
@ngn I tracked it down. it was the opposite, i.e. the keys having duplicates but the values being unique
16:43
codegolf.stackexchange.com/a/171410/95516 @ngn would it be possible for you to make an explanation for this answer?
ngn
ngn
@rak1507 ha! explaining that would be very challenging :) that answer is from more than a year ago, it's like new code to me. i'll try
thanks, no worries if you can't, I can try and decipher it
ngn
ngn
@rak1507 have you done any knot theory before? or at least something related to topology?
Nope... a tiny tiny amount but really nothing of any substance
ngn
ngn
17:04
@rak1507 btw, when i first saw that challenge it was not very clearly explained, had only 2 tests, and even they were incorrect
lmao, yeah I saw that mentioned in the chat
ngn
ngn
but i liked it so much, i spent a week trying to understand knots and polynomials and stuff, i prepared some tests, the community reopened it, and i added a 500 rep bounty, but it expired without anyone solving it (the brainflak solution came later), so i posted this as proof that it's possible to solve
I spent some time researching on this codegolf.stackexchange.com/questions/197129/…, trying to find some sort of invariant but I didn't really get far
But I did find that challenge, and it looks like that produces an invariant of some sort
So that could potentially be used
ngn
ngn
@rak1507 it doesn't. the bracket polynomial is not an invariant. there are other polynomials that are.
It says '(Again, most knot theorists compute the bracket polynomial as an intermediate product on their way to computing the Jones polynomial, which is invariant across all transformations, but we will not be doing that.)'
so the bracket polynomial can be used to compute a different one maybe
And then that'll work
ngn
ngn
17:09
yes
i would suggest reading wikipedia instead of trying to come up with an invariant polynomial by yourself. it took humanity centuries to come up with good invariant polynomials :)
I was going to use the Jones polynomial and calculate that from the bracket one maybe
ngn
ngn
@rak1507 did you learn some k already?
not enough to decipher your solution yet
I guess I could look online for other ways of calculating it but I haven't found many resources
ngn
ngn
but i don't have to explain how primitives and basic idioms works, right?
e.g. !2#n being "odometer"
17:25
no
ngn
ngn
great
what does 'syms oom' mean?
ngn
ngn
@rak1507 my impl uses a predetermined amount of memory dedicated to symbols. "oom" means out of memory - shown when the limit is exceeded.
makes sense
ngn
ngn
is there a need to raise the limit?
17:31
nope
 
2 hours later…
ngn
ngn
19:07
cmc: given a list of even-length int lists, pad them with 0s so they are centred, e.g. (1 2;3 4 5 6 7 8;9 1 2 3) -> (0 0 1 2 0 0;3 4 5 6 7 8;0 9 1 2 3 0)
19:22
cmc?
ngn
ngn
chat mini-challenge (stackexchange jargon)
19:46
@ngn r:{y(n/(!n)-2\x-n:#y)};{m r'(m:#'x)_'(,(|/#'x)#0),'x}
your link is broken
why does it break? because no http:?
it only works with ktye because of i\ div and i/ mod
noob question: is there a flip adverb (I think that's the right term) like ⍨ in APL?
@rak1507 no, not in general
damn
and there's no rotate?!
19:55
@rak1507 maybe ngn has it.
@rak1507 rotate:{x_y,x#y}
where's my ⌽ :(
|
ah, you mean the dyadic version? you see, k has less primitives in general. but is rotate needed that often? even if, it's easy to define.
@ngn I think this works
@rak1507 NYI in golf.k =P
@ngn that works for positive rotations. an obvious overload would be to handle negative integers
20:07
what absolute mad person decided % would be a good symbol for division!
ngn
ngn
@rak1507 iverson. % is the one that looks closest to ÷
is there a 'statement separator' ?
ngn
ngn
@rak1507 ;
@rak1507 what else should it mean?
thanks
@ktye modulo
I guess it makes a bit of sense
ngn
ngn
20:23
@rak1507 "flip" in k is usually a synonym for "transpose", monadic +
@coltim well done. i'm sure you can shorten that
@ngn you use idiv for 3%2? is that new?
ngn
ngn
@ktye original k returns floats, but ngn/k has been returning ints for a long time
@rak1507 just so you know: in the original k6 mod and intdiv are y!x and (-y)!x respectively. in k9: y\x and y/x (yes, args are swapped even for div)
ngn
ngn
@coltim i have 25
@ngn i get golf.k error message here: ngn.bitbucket.io/k/…
ngn
ngn
20:37
@ktye leading spaces mean continuation lines
there's an invisible \l golf.k before the other lines :)
@ngn hmm. what's the point of continuation lines?
ngn
ngn
@coltim sometimes a lambda can't fit on a line
f:{something
   something}
@ngn like separate statements? why can't it just scan until it hits a "}"?
I know some earlier k's had implicit ";"s at the end of lines
ngn
ngn
@coltim maybe it can if the file is parsed in one go, but it seems easier and probably more efficient to grab a group of lines, parse them, execute them, forget the asts and anything associated with that, and move on to the next group
@coltim all ks have that, afaik. in k code, ";" and "\n" are treated the same way
20:53
@ngn ya learn something new every day. it seems to be (another) difference between q and k
i parse everything. that may only be a problem with huge generated programs.
21:05
@ngn not anymore for k9
ngn
ngn
@chrispsn what's the new way?
@ngn mod div
ngn
ngn
uh.. i should've guessed
@chrispsn but the args are still swapped
21:25
@ngn I dunno how, but 24 bytes
ngn
ngn
@coltim nice! my 25 bytes were {p,'x,'p:&'-2!-m-|/m:#'x}
oh hmm, -1 with |x,0 instead of 0,x,0
@ngn hmm so -n!x is intdiv too?
ngn
ngn
@coltim yes, heritage from k6
@ngn folds arms and here I thought % being intdiv was okay
21:42
@ngn bug?
nyi error:
-6$'(1 2;3 4 5 6 7 8;9 1 2 3)
I came up with {p,'x,'p:{x#0}'{x%2}@-l-|/l:#'x}
I gave up with the rotation
ngn
ngn
@chrispsn if -6$1 2 is nyi, so should be that one, no?
best i got in k9 so far is ++(2 div M-L)_'(-M:|/L:#'x)#'x
@ngn oh. for some reason i thought -6$1 2 was ok
ngn
ngn
@chrispsn for now (-n)$ works only with strings
and might pad with 0N in ngn/k anyway
21:48
I miss ⍨
ngn
ngn
@rak1507 you're still under the influence of apl. breathe! :)
i find it easier to read bracketed stuff than commuted verbs
only one char more
but if you want to do it multiple times, you end up with lots of nesting and it gets confusing/ugly
{x#0}'{x%2}stuff vs ((stuff)%2)#0
I don't really like the second one
would rather do 0#⍨2%⍨stuff
ngn
ngn
@rak1507 most primitives in k (and maybe apl too?) were designed so the left arg is more likely to be a term, and the right arg a longer expression
yeah that makes sense
% and # are exceptions I guess
ngn
ngn
21:50
-2!x is x div 2 (in k6)
it seems more likely to me to do expression div 2 than something div expression
@ngn ah cool
ngn
ngn
@rak1507 instead of x#0 you can use "where" (the original from which apl took ⍸⍵): &x
I saw that
that was clever
Another thing is the use of ' a lot, is that fine in K unlike ¨ in APL?
ngn
ngn
@rak1507 yes, eaches (') and flips (i.e. transposes: +) can do any equivalent of ¨ and
sometimes you may need eachleft (\:) and eachright (/:) too because k has no enclosed scalars
and the performance is fine vs trying to do something that works on a whole array? (if you can even do that)
ngn
ngn
21:55
i mean, there's no equivalent of apl's ⊂0 1, only ,⊂0 1 - the latter being k's ,0 1
@rak1507 building off of @chrispsn's comment, this could also be #[%[stuff;2];0]
I forgot you could use [] to apply to a function
ngn
ngn
@rak1507 k works better on leading axes, so we prefer wide rather than tall matrices, and this preference is reflected in some of the primitives, e.g. odometer !2 3 4. per-row overhead is negligible for wide matrices
- 2 in k9... {x@'-(2 div M-L)-\:!M:|/L:#'x}
@ngn alright cool
22:00
{x@'((L-M)%2)+\:!M:|/L:#'x} ...
@rak1507 the same principle from APL applies - if you each a function, it needs to either be called few times, or do a lot of computation. {1+x}'!10 is still very much bad
ok I think this is my cleanest 23 bytes
@dzaima right yeah, but it seems less bad than in APL
or you should go to less effort to try and not use it maybe
ngn
ngn
@coltim wow. and {|x,0}/ -> (|0,)/
@rak1507 I think each being more is just a consequence of no rank and embracing vectors. k does have the advantage of static parsing though, which does speed up execution of scalar code
22:05
oh yeah that's true
interesting stuff
@ngn isn't this equivalent to 0|/ in older K and 0|/: in newer? (max over, with 0 as initial argument)
ngn
ngn
@beagle3 / here is "converge" "n times do", because the function is monadic and there's an int on the left
Oh, I see. I only saw the latest, didn't follow the entire discussion ..... apologies.
ngn
ngn
@beagle3 no problem. the relevant link is here
something to impress @rak1507 with (i hope) - in k n monad/x is like apl's f⍣n⊢x. can you guess what n monad\x is? :)
iterate/dzaima APL character that I can't be bothered to type?
ngn
ngn
22:15
@rak1507 yes :)
ngn
ngn
@dzaima a "T" with 2 dots on top, if i remember correctly?
@ngn yep,
yeah that one
ngn
ngn
note the beautiful symmetry between / and \ :)
22:16
it is nice I have to admit
how do you do windowed reduction in K?
oh I think I saw it in the oK docs
ngn
ngn
@rak1507 in k6 there is n'a which is like n,/a in apl, and then you can each on that. idk about k9.
Huh, why is ': a thing then?
ngn
ngn
@rak1507 also: ints\ encode; ints/ decode; str\ split; str/ join
@rak1507 iirc it changed between k5 and k6 so i kept both
@ngn is there an APL /, replicate?
ngn
ngn
@rak1507 we don't do replicate. we do at-where
22:22
now that is cool
@rak1507 these overloads are gramatically monadic operators binding to the left arg, this forms a derived function that is monadically applied to the right argument. k was running out of symbols.
although @ indexing seems almost the wrong way round for the name, "array at indices"
@rak1507 "[items from] array at [positions] indices"
@rak1507 normally you don't need it. a@x is a x. it's only needed if a monadic verb follows, which would be interpreted dyadically otherwise. or use (a x)&..
@ktye aha makes sense
I like how arrays seem syntactically the same as functions that return what is at an index
ngn
ngn
22:30
@rak1507 yes, one of arthur's greatest achievements is the unification of syntax for array indexing, function application, and dict lookup. few languages do that.
it's certainly interesting, I don't know if I like it or would prefer it over different things but it is definitely an interesting idea
@rak1507 I like it too, but it's less so in k9; f#L is filter if f is a function, but L#L is intersection; not sure if there are any other places where the equivalence is lost.
to me function application and array indexing/dict lookup are two very different ideas so unifying the two seems a bit odd
@beagle3 well, A#B is 'filter if in A from B'
so it's sort of similar
@rak1507 yes, but one of the charming (for me) things about the prior unification is that you can replace a function with a cached version of it (array or dict), and in k4 it just worked . Now it only mostly works. There are other "almost equiv but not quite" things; e.g. if you have a list L and a dictionary version of it d:(!#L)!L (! is iota, # is rho).
2
yeah that's a nice point (the caching)
22:36
They would be interchangeable for most things, but !d gives !#L and !L is not the same thing
ngn
ngn
@rak1507 python and js do those 2, but not function application. so it's not entirely odd.
yeah, arrays are like dicts but with indices as the key (conceptually) so that makes sense that those two are similar, but functions seem entirely different
ngn
ngn
"associative array" is another term for "dictionary"
all three of those (arrays, dicts, funcs) map values from a domain to a range
@rak1507 Mostly in the sense that functions are "read only". K bridges the gap between them in other ways as well - for example if f[x;y;z] is a function and a[i;j;k] is an element in a 3-dimensional array which yield the same values, then projections like f[x;;z] and a[i;;k] are as-compatible as the original f and a elements.
@rak1507 if you squint, you can imagine an array being a function that takes indices instead of arguments
@ngn this basically
22:42
@coltim yeah that's what I mentioned earlier, it does sort of make sense, I like it!
ngn
ngn
i must disappear, sorry
@beagle3 hmm, I hadn't considered that downside

« first day (686 days earlier)      last day (849 days later) »