« first day (921 days earlier)      last day (614 days later) » 

12:00 AM
what about something like 'except in unicode supporting ks (notably oK)...'
 
ngn
@rak1507 some ngns are not sure, notably the one you're talking to :)
 
lol
as long as oK is the only one that uses unicode that's fine, it's just surprising that there's only 1 (or maybe not considering the k aesthetic of keeping simplicity)
 
ngn
well, in js it is simpler to use unicode than restrict to ascii
 
good point
 
unicode is hell
 
12:08 AM
^
Also JS is technically UTF-16
 
ngn
true
also, technically k supports any single-byte encoding, not necessarily ascii
ascii is only 0..127
i wonder if the people who were designing ascii at the time realised how much impact it would have on the world.. it's hard to imagine a single-byte (or multibyte) encoding used now that's not ascii-compatible.
 
ngn
1:02 AM
k-themed challenge:
2
Q: Simplify K projections

BubblerBackground K functions have a feature called projection, which is essentially partial application of values to a function. The syntax for projections is a natural extension of the regular function call syntax: f[1;2;3] / call a ternary function f with three arguments 1, 2, 3 f[1;2;] / the ...

 
 
1 hour later…
2:13 AM
now there's an interesting puzzle
seems like you could have just left the "f" off of the input and output, bubbler
 
ngn
it wouldn't look like k tho
 
3:14 AM
^
 
3:58 AM
@ngn good challenge
+50 rep for a K answer without eval
 
ngn
@Razetime thanks on behalf of @Bubbler :)
 
ngn
4:53 AM
i have 76 bytes so far
 
cool
I assume there'd be an amend somewhere?
 
ngn
not now but it might appear later
 
i see
 
 
5 hours later…
9:37 AM
@ngn can you explain a bit how &/~=/2#+-2!<'+,/ works? I think I understand what it does, but not why applying it gives the right answer. Grade the coordinates, flip, div 2, flip again, take the first two....
 
ngn
10:00 AM
@xpqz sure
+,/ just rearranges the input in a more convenient form
so we get a 2x4 matrix: all 4 x coords in the first row, and ys in the second row
at this point we've split the problem into two independent problems - by x and by y. we're gonna combine the results at the end with &/
<' grade each. note that 0 and 1 correspond to the first rectange segment and 2 3 to the second
0 is indistinguishable from 1, so we want them to be the same value. same for 2 and 3.
-2! is "intdiv by 2" and it turns 0 1 into 0, and 2 3 into 1
at this point only 6 patterns are possible: 0011 0101 0110 1001 1010 1100
only the first and last pattern (0011 and 1100) should give a falsey result, all other cases represent segment overlaps
so, we just take the first two items and compare them (with "not equals"): ~=/2#
oh, i skipped the flip.. it just lets us work on both subproblems simultaneously
that's it.
 
@ngn 71 so far...
 
ngn
@chrispsn my best atm is 68
 
@ngn sorry - same @ 68 (had a comment in there)
 
ngn
it feels like it should be a lot shorter but i can't find promising ways to attack it
 
i am using dicts
 
ngn
10:14 AM
huh. i'm using recursion :)
@chrispsn shall we share solutions or not yet?
 
@ngn one sec
admittedly not tried against all input yet
 
10:52 AM
@ngn ah! ty
 
ngn
@chrispsn nice. one byte shorter than mine
 
ngn
11:10 AM
@chrispsn an easy -1
 
@ngn ty. i was thinking 'cut where [' could simplify the splitting but it was a little longer
 
ngn
62 by turning it into a composition
 
11:24 AM
if 'string join' worked on dicts... ;)
group might be a more efficient way to split
 
 
1 hour later…
12:59 PM
@chrispsn as in ","/,'1 2!"ab"
 
1:25 PM
@ngn I get a segfault with ."6:",1_"f[1]"
 
1:46 PM
something like this feels closer to working than it should
 
1:59 PM
@ngn Oh, look -- it works in APL, too, unsurprisingly: {∧/≠⌿2↑⍉⌊.5×⍋⍤1⍉↑⍺,⍵}
 
 
3 hours later…
5:04 PM
My solutions to the 2015 problems (with ample help from you all): gist.github.com/xpqz/79f7af15b7bd292ac075232c6ab8d931
 
5:39 PM
this formatting scares me
 
I guess you'd stringify each row, and pad with spaces to center on the one below
 
I have 45 bytes
I half remember some snippet to center text, although there's no K answer on this codegolf question
 
Ha. Now I feel like I shouldn't have give up so easy.
 
 
2 hours later…
7:42 PM
Jan 22 at 19:07, by ngn
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)
 
@Traws ah that was the one!
 
ngn
8:01 PM
@xpqz how do you test that?
@coltim 42
 
8:24 PM
nice!
two ideas: 1) `k pretty-print should do that table formatting thing argued about here a while back and 2) it would be much shorter with ⎕FLIP:`center; (presumably adding trailing whitespace as well, which would be OK)
 
ngn
1) i don't want to diverge too much from proper k by redefining the meaning of `k@
pretty printing should be the concern of repl.k
2) joke? :)
 
8:49 PM
don't suppose anyone knows if there's a way to 'drop into' k from q? you can still use the k primitives but you have to do like (!)10 which is ugly
 
ngn
also: the remark about kdb+/q here
 
doesn't seem to work in scripts, only in the repl
 
ngn
@rak1507 try prefixing all lines with k)
 
ah, that seems to work
bit of a pain lol, it's almost as if they don't want people using k
 
I know, should have put a :P or something
 
poor k :/
 
ngn
@rak1507 correct - they don't! they want to sell you q as a database, not give you k as a general-purpose programming language :)
 
I just want to write ? instead of distinct, is that so much to ask :P
they could've at least gone with uniq...
it's totally weird, they have long names for the primitives (the things you use a lot and can remember easily) and then short cryptic names for all the other utility stuff (the things you don't use a lot and probably can't remember easily)
 
ngn
@Traws "poor", quote-unquote :)
 
9:05 PM
it seems the wrong way round, primitives should be a one/a few chars and utility things like 'url encode' should be full words not .h.hu
 
ngn
@rak1507 iirc single-letter namespaces are "reserved"
 
yep 'all single letter namespaces are reserved' code.kx.com/q/ref/doth
I just wonder what the rationale was having primitives = long and other things = short
 
ngn
@rak1507 i agree that doesn't look right
short is generally preferable, so ideally both would be short
but you know, a userbase coming mostly from sql..
(probably apl too, but those are too few to matter)
 
@rak1507 so the common things look readable probably
 
@dzaima but the common things are common, so even if they're unreadable at first you'll know what they do within like 5 minutes
but if you see .h.hu for example you have no chance of guessing what it means, and it probably doesn't come up very often
the logic seems flipped from what it should be
 
9:14 PM
@rak1507 but you won't get past 5 minutes if you want SQL and all the examples look like line noise
 
eh maybe but even keeping the select stuff it wouldn't look too bad
if you just want SQLy things you're probably not writing much 'actual code' anyway
 
primitives were short but probably a lot of people complained.. I imagine arthur whitney refused the change for as long as he could
 
so you can learn +/ # etc
@Traws :( people always ruin things
this is why the best programming langs have no users :P
 
@rak1507 yeh I think / and `\` in scripts are the multi-line comment syntax
@rak1507 hmm. I can see two usecases for heavy usage of SQL-y things; data science-y type stuff (basically whatever folks use numpy/pandas for) and things that shuffle a lot of data around
 
the moment you start writing actual q code anyway any illusion of being a 'normal' language is quickly shattered when you have to do $[] for if statements and whatever, idk why learning # means count and / means fold was too hard for people
 
9:34 PM
@rak1507 I think I read/watched something that mentioned that the dyadic versions were kept since they're more familiar (presumably meaning the arithmetic ones like + or *, even though things like x#y and x_y would still be unusual coming from other languages)
 
dyadic ones being kept and monadic not being kept is crazy too...
monadic #: no! too complicated! must use `count` instead
dyadic #: sure, everyone knows what that means right
 
don't forget the overloads on things like _ (let alone x!y!). I think there's an entire group of programmers who hate overloads
I mean I guess it's like, there are a half dozen/dozen "ugly" parts of K (or other array languages) to those coming from the more common languages
q gets rid of like 3-4 of them (from that perspective?)
 
I wouldn't even go that far, maybe 1 of them (funny symbols for monadic functions), all the other 'ugly' parts are still there
 
For that CMC, Arthur whittled it down in k9 to +,/(|+|';+)@'+2^' though haven't tested it recently
 
@rak1507 depending on the K I would include things like if[c;expr1;expr2;...] plus all the defined/keyworded functions. and the SQL stuff itself is a nice stepping stone (given that a "select col1 * col2 from table" "vectorizes" the way it does in array languages)
 
9:45 PM
There was also this in k7
 
ngn
@chrispsn which cmc?
 
@chrispsn that can work in ngn/k, even being golfed a bit
 
@ngn yeah, sorry
 
ngn
10:06 PM
it would be nice if we could build a library of such useful expressions
unfortunately there can't be cooperation between k6 and k9, they are too different
 
10:18 PM
@ngn yeah, it would. something like aplcart has been suggested.
 
ngn
@Traws that's easy to code but collecting good content, tagging it, and organising it is a lot of work
 
@ngn yeah, ideally it should be hosted in a way that makes collaboration very easy.. don't know if wiki is the right place though
 

« first day (921 days earlier)      last day (614 days later) »