« first day (920 days earlier)      last day (615 days later) » 

2:01 AM
@ngn intensely
 
 
2 hours later…
 
4 hours later…
8:43 AM
@ngn I see you've provided me with some golfs to learn from, too
 
9:34 AM
@ngn Speaking of those golfs, I am baffled by this:
|:\"racecar"
,"racecar"

|:\"racecars"
("racecars"
 "sracecar")
Why does that work like that?
To the best of my reading that's a scan of a monadic reverse.
 
\ there is "converge"
 
:/
 
see e.g. {10!1+x}\3
 
I sense that this will be a challenge in k. Every symbol means at least 10 different things.
 
/ and \ are especially crazy though
 
9:42 AM
So (parse-wise) how can I spot that this isn't a scan?
 
it seems to that the function is monadic, but that's not really guaranteed knowledge at parse time
 
so monad\something is always converge.
I guess I can convince myself of that.
Am I right that in APL, the forward slash version is , but that there is no direct correspondance for the backslash version?
 
yes
 
Every day is a school day.
 
10:11 AM
for what it's worth, k9 changes the syntax for the 'while', 'do n times' and 'converge' adverbs to (as i understand it) better distinguish those situations from others such as each-left/right. see guide here
 
 
1 hour later…
11:29 AM
@ngn i'm laughing, whats so special about the o ? (https://ngn.codeberg.page/k#eJxLM7SqViixqtBRskpITEhSNFQwUlKw1lMosa7Q0auo5UpMtFJKTEpOSU1Lz8jMys7JzcsvKCwqLiktK6+orFLiSjNUT0zkAgDwABaA)
also i see it automatically defined, inputting it in empty session just returns o compared to any other letter that just gives back `val error . please show me c/k source regarding this if there is one.
 
o is the reference to itself for recursion (idk if you know APL but it's like ∇)
 
thanks, nice to know. none exp in apl.
 
12:25 PM
@xpqz don't forget about things like ,// which combine these pieces together =P
 
12:37 PM
@coltim Wow, just realised how that works......
Wha's the most k for calculating standard deviation? Anything I write is either long or ugly, or both.
square:{x*x}
mean:{(+/x)%#x}

stdev:{%(mean square x)-square mean x}
or {%(+/k*k:x-(+/x)%#x)%#x}
 
ngn
1:04 PM
/ reduces rank, \ preserves rank
 
@ngn Yeah -- I'm intellectually aware of them. Just can't stop my eyes yet from seeing "scan" every time I see a back slash.
 
ngn
when f is monadic, f\ is a kind of scan, in a sense, only over the infinite sequence x;f[x];f[f[x]];..
the left arg specifies the stop condition - a number means "do that many iterations"
a function means "iterate while it's true"
no left arg means "iterate until it converges"
 
1=#|:\ is an ingenious way of saying {x~|x}
 
@xpqz the : is force monadic ?
 
Yep
 
ngn
1:17 PM
@xpqz that doesn't look ugly to me. some ks have a "dev" keyword.
 
@xpqz so what makes the \ return 1 element or 2 elements? i don't get it. what makes it so? ( what a dangerous area of experimentation - i got my browser locked up a couple of time )
 
It's well explained by @dzaima above -- but what it says is repeatedly apply monadic reverse until you encounter a value you've already seen. For a string that must be either 1 (for a palindrome) or 2 (for a non-palindrome).
 
@xpqz it's a bit more nuanced, in that it stops when two successive iterations return the same value OR when an iteration returns the original input
loops beginning a few iterations in won't stop the iteration
 
Ah, ok - so it's not any previous value, it's either the original, or previous.
 
either original or previous, got it, thanks. do you know where it is located in the c-source? (this functionality)
 
So raze ,// means keep ravelling until there is nothing more to ravel. I think.
 
ngn
@xpqz yes, because ,/ (like any other f/) is considered monadic, even though it can be overapplied to more args
 
@ngn _mtc what it do?
 
ngn
@meyt4r it tests if two k objects match (i.e. are equivalent)
enl( ) is enlist (monadic ,)
app( ) is apply
dex( ) you know already
 
what the cabalistic meaning of m t c ? just a short hand for match? no hidden words.
 
ngn
1:42 PM
@meyt4r that's right :) match
could have been mat() or mch()..
btw, cs() ("converge-scan") is one of the most complicated overloads, it takes a full line to implement
/ and \ are on my list of most beautiful primitives in k, together with @-unification (list@index, func@arg, dict@key sharing the same syntax), and the design of dyadic, triadic, tetradic etc @ and .
 
2:00 PM
No tacit to speak of and no selfie makes k easier to learn than APL. At least once you know APL already :)
 
ngn
@xpqz funny how things that were considered foreign to apl only a few years ago are now seen as an integral part of it
 
ngn
2:23 PM
@xpqz @meyt4r once you've mastered the basic cases of / and \ pls remind me to explain the triadic version F/[x;y;z] :)
 
@ngn found a single test case for what u speak of (t.k l:79). so might figure it out by myself ;).
help me to fill this out (https://ngn.codeberg.page/k#eJxNj80KwyAQhO95ijl6akj6ANK3yFXWpQRSlV1aX7/+VSoM8w2zLroi32hZ8dgNB0JR9NyzZ0LRzPkMKPIx17wZTReKTmr9YdjRCxPR8F5x75RluALWWrSj5EJfTwJQDB+WJ0PYv4nb2Gj1r/1dOswlw7W7eOqgFOZYfUTa67LxUZe25QtVPUN3)
 
ngn
@meyt4r but i want to reserve the right to rename things..
wr "while reduce", ws "while scan"
lr "loop reduce" - it dispatches to the appropriate form of loop (n-do or while or converge)
ls "loop scan"
eac "each", eal "each left", ear "each right", eap "each prior"
 
@ngn should have thought about it before you wrote awesome soft that others started to use. jk, i don't care. rename things whenever however you like. and by the end of the day, we'll get to know you better. so even when u rename stuff. we'll probably guess what you mean.
 
ngn
the others are not very important: eac2 "each with 2 args", eacm "each for dictionaries (type "m")"
 
got ya, andddddd saved.
 
ngn
2:39 PM
i think you're missing the n-do overloads: nr() and ns()
 
also jc jC sCC scC ( i got them seperated by k funcs and c funcs )
 
ngn
jc "join with char atom", jC "join with char list"
sc "split by char atom (the right arg is a k object)"
sC "split by char list (the right arg is a k object)"
scC sCC - same like sc and sC but the right arg is char*
 
Is there a way of doing destructuring assignments? I tried (a b c):1 2 3 but that doesn't work.
 
ngn
@xpqz (a;b;c):1 2 3
there's no stranding. a b c parses as a[b[c]]. list construction/destruction requires explicit ( ; )
1 2 3 looks "stranded" only because it's parsed as a single token
 
2:55 PM
@ngn im telling you people don't even know about the dark art of naming things. seems to be a forgotten art, practiced properly only by previous centuries grimoire writers. a proper dictionary of symbols is a must to any programmer worth its salt. and i am afraid its the only proper way to understand complexity in a reasonable amount of time. meditating upon lines of symbols is basically compiling into your own understanding, your own mind the source, so you can either fix or manipulate it.
thanks for reading my blogpost.
 
ngn
@meyt4r sounds philosophical
@meyt4r where?
 
@ngn it just an ending statement. like god bless you and the like.
 
3:26 PM
Anyone for problems.tryapl.org/psets/… ? I have 28 chars k, and 19 in Dyalog, both including surrounding {}.
 
ngn
3:41 PM
@xpqz nice problem but the tests are so weak
 
If you mean the examples, it's "intentional" I think. There is a richer test suite once you submit your solution.
 
ngn
but those are not public, i guess..
 
ngn
@xpqz ah, thanks :)
wait, they generate random inputs, how do they know what the correct output should be?
unless they've included the solution in the tests :D
 
They include a model solution, so I assume they check that yours generate the same results as theirs.
 
ngn
3:51 PM
do different people get different tests?
they don't reset []rl afaics
 
I haven't actually checked how the tests are applied; it's possible. Not all questions have random test data. From using the site, the submission seems to be tested in three different levels: the given examples, several examples for the "happy path" and (in some cases) specific edge cases (like empty input). If you get an error, they will showthe input and the output they expected.
 
ngn
those parens around ⍺, lol :) somebody must have been so busy writing tests, they didn't have time to look at what they've written :)
 
I think.
@ngn I've fixed a couple for them.
 
ngn
it's a nice challenge though
 
But I guess the hidden model solution need only be correct, not pretty
The model solution here (alpha-brackets withstanding) is great though.
I tried translating it to k, but it's longer.
 
ngn
4:02 PM
@xpqz yes, good one
 
From k not having built in for sgn, abs and outer product
 
ngn
i guess we just have to think differently in k
 
Was thinking it might be possible to make up all 8 points, sort them, and see if the first 4 all belongs to x.
 
ngn
does it matter what it returns for a corner overlap (just one point) or edge overlap?
 
I think from the test cases, a shared edge or corner counts as not overlapping.
My best k version was {~+/4=|/-:\+/,/-/0<-:\x-\:y}
A direct translation, give or take
Including your hideous abs() :)
 
ngn
4:07 PM
@xpqz nice!
slightly shorter as a composition: ~+/4=|/-:\+/,/-/0<-:\-\:
 
I wonder what that would match if applied as a regex.
 
ngn
..or piped into perl or j or bash.. :)
 
ngn
4:22 PM
@xpqz i have something equally short but it takes (x;y) as a single argument
&//(</(&/';||/')@\:)'++'
@ngn actually, that seems wrong for other tests
 
ngn
4:39 PM
@xpqz your solution seems to fail for f[9 1;4 7]
 
@ngn sometimes a fancy feature is the reason someone learns a new language, and that feature becomes what they think of as the heart of the language
 
ngn
@JohnE right
@xpqz i think "outer product" can't be just -\: when x and y are matrices
 
imagine how funny it would have been if iKe got really popular and suddenly the K community was filled with graphics people and people interested in livecoding who thought of applications to finance as a curiosity! :)
 
ngn
40y ago: "imagine this military communications network being accessible from every home" :)
 
same for the internet and GPS
 
ngn
4:50 PM
internet - exactly
 
remember when PS3s got a folding@home client and overnight the addition of thousands of what was technically a children's toy to the network doubled its compute capacity?
 
ngn
i'm not much of a gamer (except for stupid simple games)
@xpqz if you replace -\: with -/:\: it works. or at least agrees with my solution :)
 
ngn
5:45 PM
@xpqz 17 bytes: &/~=/2#+-2!<'+,/
@xpqz so it's even shorter than your 19 in dyalog :)
oops, there was a trailing space..
so that's really 16 bytes: &/~=/2#+-2!<'+,/
 
6:12 PM
@ngn getdents, is that a syscall? is there a portable replacement?
i tried to complile ngn/k with gcc 9.1 on windows. replaced first 2 lines in opts with -Dlibc -lm and had to uncomment include<sys/syscall.h> in 0.c
Every object file compiled but link failed with undefined getdents.
 
ngn
@ktye yes, a syscall. one of the most problematic ones - it works very differently even between linux and freebsd
 
i replaced it with return -1 and it compiles.
 
ngn
ooh, nice
@ktye on windows, i assume?
 
The binary seems to work, but the test during the makefile failed badly. (many lines of failed loading shared library..., than the terminal window disappeared)
@ngn yes windows with mingw gcc-9.1.0 from msys2.
 
ngn
well, it does need to list a directory for some of the tests
dirents means "directory entries", btw, it's what commands like "ls" use
 
6:25 PM
@ngn does it read the directory content for every test case?
 
ngn
@ktye only for those that are split in separate files - a19/* a20/* e/*
there's a .k script - l/runparts.k - that lists those directories and runs the .k files in separate processes
 
i think it fails for each test: it starts with:
unit tests
size:182272
.k.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

fail:-1 23 -45 -0 0N / -1 23 -45 0 0N
 
ngn
oh, so it doesn't work at all then
@ktye what are the first few lines of "opts"?
and what command-line flags do you pass to the linker?
 
@ngn only with make test tests. in the repl it's fine.
this is the diff:
diff --git a/0.c b/0.c
index d8da41c..2c52407 100644
--- a/0.c
+++ b/0.c
@@ -1,6 +1,6 @@
// ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - https://codeberg.org/ngn/k/blob/master/LICENSE
#include"a.h"
-#include<sys/syscall.h>
+//#include<sys/syscall.h>
#include<stdarg.h>
#include<stdio.h>
#include<fcntl.h>
diff --git a/i.c b/i.c
index 65c1298..7eabf4d 100644
--- a/i.c
+++ b/i.c
@@ -9,7 +9,9 @@
#undef __USE_EXTERN_INLINES
#include<sys/stat.h>
#include"a.h"
-ssize_t getdents(I,char*,N);
+
first 2 lines of opts are replaced as you told us.
 
ngn
@ktye i think -lm should be given directly to the compiler at the linking step (makefile:27)
at least when i tried to put it in opts (like you've done) it didn't work
 
6:36 PM
i get this: `sin 0.5
0.479425538604203
 
ngn
yay, so libm works :)
can you load files with \l from the repl?
 
it's an 'io error.
Does it need getdents to load it? not just open?
 
ngn
getdents() - no. it needs open() mmap() fstat() close()
mmap() is the most likely source of trouble
 
 
1 hour later…
ngn
7:48 PM
is there a k impl other than oK that treats non-ascii characters as atoms?
the second paragraph in k.miraheze.org/wiki/Comparison sounds a little vague
 
 
3 hours later…
11:10 PM
afaik every other K just has bytes as characters
oK uses a list of codepoints because it's easy when implemented on top of a language that already supports unicode
 
ngn
11:46 PM
i think it's wrong to say "ascii" (in the wiki) when characters can have values beyond 128, but i don't know how to rephrase it
 
what about 'Character comparison is either done based on character codes or byte values depending on the implementation' ?
 
ngn
vague. obscures the fact that oK is the only one that supports unicode.
@rak1507 "Characters are compared as bytes (0..255), except in oK which supports Unicode and compares characters by their code points." ?
 
What about 'Most ks don't support unicode, and therefore comparison is done on raw byte values'
@ngn yeah, something like that
 
ngn
actually, i think i'd better drop the "0..255" part
 
it's probably unnecessary
 
ngn
11:52 PM
saved. if someone wants to rephrase again, feel free :)
 
is oK definitely the only one which supports unicode?
 
ngn
i would be very surprised if it isn't
i think generally it's better to mention specific facts about specific implementations in the wiki than use vague phrasing like "some implementations"
iirc wikipedia calls those "weasel words"
 

« first day (920 days earlier)      last day (615 days later) »