« first day (694 days earlier)      last day (1961 days later) » 

2:35 AM
Idea: do all the AoC starting at 11:36 PM 12/24
 
 
7 hours later…
9:07 AM
@ngn I tried to solve https://codegolf.stackexchange.com/questions/177826/smallest-diversifying-exponent using oK and just then I realized it doesn't have arbitrary integer precision.
Btw, can you take a look at my solution?
`f:{{$[10>#?$*/y#x;o[x;y+1];y]}[x;1]}`
 
ngn
@GalenIvanov sure. i'll need some time to read the challenge first
 
Thanks!
Why does the formatting not work in my post...
 
ngn
@GalenIvanov formatting doesn't work in multiline messages, i often fall for this too...
 
@ngn - ahaa! Thanks!
 
ngn
the usual workaround is to split your message in several parts
 
9:16 AM
Ok, I'll try to remember it
 
ngn
@GalenIvanov unfortunately the challenge requires too many bits :( e.g. 35^19 is almost 2^100
otherwise, you solution works theoretically
 
@ngn Yes, I realized that after a while
I like K, it's really consistent and easy to use
 
ngn
i don't think any k impl has big numbers like j's 1x
 
Apparently - I tried Kona, it's the same
 
ngn
in ngn/k everything is 64-bit. in oK you're limited to 53 bits of precision due to the way ieee floating point works
 
9:25 AM
ok
That's why I solved this challenge with Racket :)
 
ngn
@GalenIvanov why not j? :)
 
Because Bubbler had already solved it in J
 
ngn
hm, i wonder how hard it would be to implement multiplication in k for lists of digits...
 
@ngn In order to use it for bigints?
 
ngn
@GalenIvanov yeah
 
9:32 AM
@ngn You can probably do it in your impl K(ngnK)
 
ngn
@GalenIvanov or do it in k and have a really long answer
 
haha, yes! :)
I started working on my wannabe vector DSL in Red language. The test for bigint addition was approx. 10 times slower then the similar code (simple Fibonacci) in Racket and Factor (I tried them because of their integrated bigint support)
btw it was in Red (interpreted) and not in Red/System (a low-level DSL in Red, in which the rest Red is written)
 
ngn
@GalenIvanov what is Red typically used for?
 
It's successor of Rebol (which is intepreted), but is a full-stack programming language.
It has a REPL console, but can be (cross) compiled too
So, it can be used for many things - from systems programming, to GUI, web-scrapping and so on.
 
ngn
"Single-file (~1MB) contains whole toolchain, full standard library and REPL. No install, no setup" - that sounds good :)
 
9:47 AM
No dependencies, the toolchain is only 1.2 MB and contains the compiler and the console; one can compile for different target on a single machine (too bad the GUI is not completed for Android)
@ngn Yes, it's real, not just an advertisement
Red's (and Rebol's) Parse dialect is cool, much more readable than regex (but really verbose for golfing)
 
ngn
@GalenIvanov by the way, ngn/k is <100 KB and its repl is 1 line of k :)
 
You are a second Arthur Withney :)
 
ngn
@GalenIvanov i'm far from that
 
btw K's lists abstraction is easier to use (at least for me) then J's and APL's arrays
It's really annoying for me to use boxing in J when the data is not the same length
In this aspect Red is similar - it's omnipresent data structure is block/series
the code itself is also a block, so it can be stored/loaded and changed in runtime
so it's reflective as well as homoiconic
 
ngn
@GalenIvanov as Adam likes to say, k turns rank into depth :)
 
9:59 AM
yes :)
 
ngn
apl and j have the advantage of working on tightly packed multidimensional data, e.g. no per-row overhead in matrices
k has the advantage of being able to deal with ragged (non-rectangular) arrays
sometimes k has to do tricks to overcome the per-row overhead
for instance !2 3 4 returns three long lists instead of many 3-lists
so... i think it's a tradeoff
@GalenIvanov is Red's speed comparable to apl/j/k?
 
@ngn Yes, you are right.
About the performance of Red - I don't have any figures
I might make some tests for simple cases. Red has a vector datatype
but it can only multiply (for instance) the entire vector by a single number
@ngn about ` !2 3 4 `
I still tend to think of it as

i#!*/i:2 3 4
((0 1 2 3
4 5 6 7
8 9 10 11)
(12 13 14 15
16 17 18 19
20 21 22 23))
(J's i.2 3 4)
and not the odometer, what's the meaning of ! in K
 
ngn
10:37 AM
@GalenIvanov my point was, k prefers matrices to be wide rather than tall, because each row costs a pointer + a header
so sometimes it ends up returning counter-intuitive results, like with the odometer, which one would normally expect to give a list of odometer readings: (0 0 0;0 0 1;...)
if it had multidimensional arrays like in apl, it wouldn't need to do this, but its implementation would be more complicated
and, of course, k's author prefers to err on the side of simplicity :)
 
ngn
11:07 AM
@GalenIvanov it took me 76 bytes, still trying to golf it
 
@ngn Thanks for the explanation!
And I wait for an explanation of your (golfed) solution
 
ngn
11:42 AM
@GalenIvanov i hope it's detailed enough
 
@ngn Yes, it's more than enough, thanks!
 
 
2 hours later…
1:35 PM
@ngn So in fact the framework of your solution (neglecting the bigint stuff) is:
f:{#{10>#?$*/x}{x,a}/a::x}
I didn't know about the global variables and that's why I came up with the verbose cond solution
@ I think it work aslo ths way, I reduce the list by * in the condition
 
ngn
@GalenIvanov yes, except i do the multiplication where you have {x,a}
 
ngn
@GalenIvanov this is a bit ugly in k ... there are no closures
 
aha
still 10 bytes shorter than the $[] version
@ngn of course one multiplication at each iteration is better than recuction of the list by multiplication at each step
 
ngn
@GalenIvanov since order doesn't matter, you could replace {x,a} with (a,) or even (x,)
k trains are straightforward (unlike j and apl)
train is like {train x}
 
1:43 PM
@ngn That's cool
I forgot the part " verbs... not supplied with sufficient arguments"
I still tend to think for a train as an expression with no noun in it
 
ngn
@GalenIvanov no noun at the end
 
ngn
you could have nouns in other positions: +/1-2*
 
Yes, right
but the argument is promoted only to the rightmost verb?
 
ngn
@GalenIvanov what do you mean by promoted?
 
1:48 PM
applied
and then the result is carried on to the left
 
ngn
+/1-2* works like {+/1-2*x}, so first it's multiplied by 2 (and if it's a list, the whole list is multiplied as usual), then subtracted from 1, etc
 
ngn
by the way, { } is a noun (i know, this does look surprising at first)
 
I didn't know it
 
ngn
due to my apl habits, i forget about it sometimes. for instance, in apl you can write things like {-⍵×⍵}⌽a but in k you must separate the lambda with an @ like this: {-x*x}@|a
or else it becomes the left argument to |
it's also dangerous near adverbs: {f}{g}/x is a while loop. {f}@{g}/x is {f} applied to the reduction of {g} applied to x
 
1:56 PM
ok
 
2:33 PM
@ngn ugh, I really dislike that about k
 
ngn
@Adám it's not much of a problem when you get used to it
 
@ngn nothing is, even java, apparently.
 
ngn
it gives k the advantage of being statically parsable, unlike apl
names are also always nouns
f:{x+1}; f|a / this is not "f applied to the reverse of a" but "max between f (as a value) and a", so it will fail
any tool (parser, syntax highlighter, etc.) can figure out what is applied to what without runtime information about the values behind the names and without having to inspect the whole source file
 

« first day (694 days earlier)      last day (1961 days later) »