« first day (844 days earlier)      last day (691 days later) » 

01:05
there's an amazing amount of test "surface-area" to a K interpreter
That statement is probably true for any high-level Turing-complete language
 
2 hours later…
03:09
@ngn I like backwards compatibility to the extent that I appreciate stability in a language. I don't want my knowledge of a language to go out of date too quickly.
03:27
@ngn welp this came up during a project euler
 
7 hours later…
10:02
x(,/{@[x;y;]'(!10)^x*|/p[;y]=p,:,3/:-3!p:!9 9}')/&~*x apparently this is a sudoku solver
it takes an 81-length vector
and returns a result
not sure what it expects empty cells to be(probably 0)
 
1 hour later…
@ngn nono, I took this from dfns.sudoku
It's Arthur Whitney's K5 solution
huh cool ngn is number 1 in bulgaria
indians are crazy
ngn
ngn
@Razetime mine is loosely based on arthur's
there's a guy with pencil/paper at #147
11:28
having a billion people probably helps :P
eh yeah i guess
also the fact that everyone's obsessed with IT jobs and math
@ngn wait what
that's all your solutions?
is X some sort of defined adverb which runs each thing?
ngn
ngn
@Razetime i don't think what most people mention as their language matches what they use in reality. most of my solutions are in python and c but i'd still like to advertise apl/j/k
@Razetime that's the first 100
yeah only 100 can be b=published right
ngn
ngn
@Razetime yes, defined near the top
and what exactly is it doing
ngn
ngn
11:32
@Razetime from PE's "about" section: "Problems 1 to 100 provide a wealth of helpful introductory teaching material and if you are able to respect our requirements, then we give permission for those problems and their solutions to be discussed elsewhere."
although people publish higher solutions all the time unfortunately
I looked one up once because I was certain I had the right answer, it was because I was pasting ¯1234.... instead of -1234...
wait, you can't even get negative answers right? must be misremembering
ngn
ngn
@rak1507 there are no restrictions. there's even at least one alphabetic answer.
@Razetime india is traditionally great at maths
ah yeah it was 27, must have looked up a higher one for a different reason
if i solve 26 problems I will be on the 35th page of the indian leadeboards
ngn
ngn
if it matters, you can always move to a small island nation and become #1 :)
11:41
nah I want 69th place in india
and i want to maintain it
this requires > 200 solves
or make your own micronation
nah i have a decent goal
and it may be possible
12:12
how do i assign at index?
ngn
ngn
@Razetime a[i]:b ?
multiple idexes also work?
ngn
ngn
yes, they should
12:33
what does mmap lmt mean?
ngn
ngn
you're trying to allocate too much memory
or maybe open too many files
haha, open too many files
it was definitely allocating too much memory
13:22
do defined verbs not work like infix operators?
ngn
ngn
@Razetime there are no user-defined verbs (except something+adverb). lambdas { } act as nouns syntactically.
like nouns?
so the only correct calling syntax is []
ngn
ngn
@Razetime yes, a lambda can be an argument to another function
oh ok functions are data kinda thing
ngn
ngn
@Razetime a[b] or a@b or a b - they are the same thing, application
for more than one arg you can use a[b;c] or a . (b;c) but not b a c
@Razetime note how "while" works, for instance: {a}{b}/c
{a} and c are the arguments of {b}/
{b}/ is a derived verb
so, thanks to {a} being a noun, it can become the left arg of {b}/
13:29
interesting
ngn
ngn
this solves the old apl problem of static parsability, and i think it's one of the best design decisions in k
what exactly is static parsability
ngn
ngn
being able to tell what the structure of the code is just by looking at the source locally, without any knowledge about runtime values
e.g. is a b c the same as (a b)c or a(b c)? in apl you can't tell. in k you can.
oh! that is very nice
ngn
ngn
yes, it offloads some of the work from runtime to compile time
13:33
I am thinking of making a k tutorial series
sort of like a video introduction
ngn
ngn
cool! if there's anything we in this chat can help with, do tell us
sure, will ask
13:50
why isn't global assignment working here? program
b is supposed to be 2
ngn
ngn
@Razetime i+::1 - why not just i+:1?
i need it to globally update?
is modified assignment global
ngn
ngn
@Razetime yes (as long as there is no local with that name)
i can't believe that was the problem
so modified assignment with :: returns a value?
that is, if there is no other local with the same name
ok one more thing
{~2=#b}{i+::1;t:b;b::.',/$|dec/|b+(((#b)-#a)#0),a;a::t}/1
I'm trying to run this
but it goes on forever
nvm it's the same problem
14:19
this program stops on the first iteration in my pc(repl): program
is there a way to load k program outside the repl?
also what is the maximum number limit in K?
ngn
ngn
@Razetime i think it parses as i+: :1 which makes the second : act like "return"
i guess so
ngn
ngn
@Razetime \l file.k should work when part of a .k file too
@ngn like, can i do ./k file.k?
ngn
ngn
@Razetime signed 64bit, i.e. 2^63 - 1 = 9223372036854775807
@Razetime yes
14:27
will it show return values
or does it need to explicitly output
ngn
ngn
@Razetime it works the same way as if you've typed it in the repl
also is there a way to get an executable?
ngn
ngn
@Razetime no.. but that could be a good idea
alright
ngn
ngn
i was thinking, what if i make the k executable self-aware of its own size, and if it detects that it has a .k program concatented to its end, it executes it
this way turning a .k script into an executable program would be just: cat k file.k > myprogram
not sure if the elf format would allow that
14:31
that is a very interesting idea
is there an equivalent to in K?
ngn
ngn
@Razetime maybe something like *(3'"abcdefgh")?,"cde"
(or (3'"abcdefgh")?"cde" in k dialects with "rank-sensitivity")
oh, there are k dialects with rank
ngn
ngn
rank-sensitivity
ok
so this is basically taking windows
and then finding first index
ngn
ngn
yeah
in 2+ dimensions it gets more complicated..
14:37
i can see why
i just need to find a recurring decimal so this 1D version works well
@ngn might also be able to do something with permitting a shebang line and then having the interpreter executable follow a \\
ngn
ngn
@JohnE #! is allowed. i'm not sure what @Razetime needs this for but yeah, if the interpreter can be in a separate file, #! is the better solution
@JohnE i don't think it would be a valid elf file if the elf header is not at the beginning of the file
it'd probably be deeply nasty to try doing something like lopping off the end of a shell script, storing it as a temp file, and then executing the temp file
ngn
ngn
@JohnE ah.. so your idea is that it should start like a shell script, not like a k file
14:53
right
i'm trying to find the first 1 in a boolean array
is *& better or ?,1 better?
ngn
ngn
i think x?1 because it stops when it finds the 1
yes, I'd guess x?,1
15:19
why am i getting 'val here?
@Razetime no lexical scope
oh hm
ngn
ngn
yep. shame on k.
@ngn you could append zip files (even recursively) to the end. they have their index at the end, so they know how much to read. but then you need unzip available or within k.
@coltim one example of how nuanced testing overloads/all different types of args can get is this - n?dict (deal) only works intuitively if the keys are 0..#dict. am I clear on what the desired behavior even is here? not really, ha
15:27
@ngn *& could be implemented as an optimized idiom.
{a::x;p::0;fr::x#0;{(~x=0) &(0=fr x)}{fr[x]::p;p+::1;_(x*10)%a}/1}13 I'm not sure why it's running forever
but without the :: next to fr[x] and p+ it just halts immediately
ngn
ngn
@ktye yes, of course
@Razetime +::1 intentional?
let me try again
15:42
ngn/k, 74 bytes: {a::x;p::0;fr::x#0;v:{(~x=0) &(0=fr x)}{fr[x]::p;p+:1;a!x*10}/1;p-fr v}983 this snippet is giving me 4 in the repl
i have no clue why
i'm not sure why i'm having so many problems with the repl
how close is K3 to K6?
also, which dialect does kdb+ use?
ngn
ngn
just a few minutes to make a cup of coffee and i'll be back..
i think I should clone the latest version
ngn
ngn
15:59
@Razetime i'm not sure but probably closer than k6 vs k9
@Razetime k4
@Razetime what does it do?
it finds the length of recurring decimal
ngn
ngn
i get 982 everywhere i try
I'm recloning
will check
ngn
ngn
shorter: fr:&a:983;p:0;p-fr{~(~x)|fr x}{fr[x]::p;p+:1;a!x*10}/1
what we usually do in such cases is drag all of the state in the loop as argument(s) and result
so here the "state" could be (x;p;fr)
i'll try to rewrite it like that..
@ngn can we omit brackets when assigning a function to a variable?
ngn
ngn
16:12
@Razetime usually yes
oh wow
ngn
ngn
f:+ /this works
f:x+y ?
ngn
ngn
@Razetime no, not like that
ngn
ngn
16:16
a:983
(x;p;fr):{(x;p;fr):x;(~~x)&~fr x}{(x;p;fr):x;(a!x*10;p+1;@[fr;x;:;p])}/(1;0;&a)
p-fr x
not too pretty but avoids closures
instead of ~~x we can use just x right
ngn
ngn
@Razetime only if we are sure that x is a boolean
huh. what if x is an int?
and positive only
ngn
ngn
then x could be different from ~~x. but since this is the stop condition of a while loop, it probably doesn't matter, as the truthiness of x is preserved
ok, here it is:
a:983
(x;p;fr):{(x;p;fr):x;x&~fr x}{(x;p;fr):x;(a!x*10;p+1;@[fr;x;:;p])}/(1;0;&a)
p-fr x
tbh, i think this looked better:
fr:&a:983;p:0;p-fr{x&~fr x}{fr[x]:p;p+:1;a!x*10}/1
yep it does
I'll add it in commented
ngn
ngn
16:26
@Razetime how big can be a?
a can go upto 1000
it's euler 26 i think
ngn
ngn
ah, so not a lot. maybe we can generate all powers of 10 mod a and use a single amend for fr
16:38
maybe, I didn't want to risk it
thanks a bunch for the help
good night
ngn
ngn
17:15
@Razetime here's another idea (tortoise&hare cycle detection): we start with 1 1 and keep multiplying by 10 100 (mod a) until they become equal again. if the last pair is 0 0, there is no recurring part in the decimal fraction. otherwise, the cycle length is the length of our sequence.
the above only finds the max cycle length. to actually solve the problem:
18:19
@ngn hmm this reminded me of a golf but the results are different? not sure I have the brainpower at the moment to figure out why
ngn
ngn
@coltim f doesn't look correct to me. it tries to find the first 1 in the sequence instead of detecting a cycle (which could consist of anything)
@ngn hmm the question's test examples could be wrong? there's this: "Given a positive integer n, (n>1 and n<10000), find the length of pattern in 1/n, if it's repeating. Otherwise, return any non-positive integer (e.g., cases: 1/5,1/94,1/22)."
ngn
ngn
@coltim 65 -> -1 seems wrong. 1%65. does look like it has a pattern
even if that pattern doesn't start immediately after the dot
@ngn ah, that would be the difference. 1/65 has that leading 0 but repeats after that
ngn
ngn
"Note that, the pattern should start just after the decimal point" (from the challenge)
18:32
ah it could be this
19:01
I wonder if it's possible to prove that they'd return the same value
 
3 hours later…
22:20
how come x\\:x doesn't work for split each left?
because \ for splitting is still an adverb
oh right
ngn
ngn
@rak1507 it's equivalent to (x\)\:x which is missing a left arg
is there anything shorter than x{x\y}\:x
ngn
ngn
22:36
probably not

« first day (844 days earlier)      last day (691 days later) »