« first day (723 days earlier)      last day (1938 days later) » 

2:23 AM
My solution to projecteuler.net/problem=1 in K: +/&~{&/3 5!\:x}'!1000
That works in the current oK interpreter.
 
 
5 hours later…
ngn
7:29 AM
@jordancurve very good. another way to write that, avoiding the lambda, is: +/&~&/3 5!\:!1000
 
ngn
8:20 AM
@Adám @dzaima k looks only at the first and the previous. kx docs
 
9:05 AM
@ngn Oh. I seem to recall some way of stopping on long loops.
 
ngn
9:46 AM
@Adám like, a "while" loop? {condition}{body}/initialvalue
 
@ngn No, I want {10|1+⍵}32 to repeat until 3 is seen again a second time. I.e. 32→3→4→5→6→7→8→9→0→1→2→3
 
ngn
oh, hang on
@Adám you could do something like this {?x,10!1+*|x}/32
i only needed to compute "next" from the last element
? is "distinct"
"distinct of x concat mod-10 of 1+ last of x, repeat until convergence starting with 32"
 
@ngn Ah, so that's {∪⍵,10|1+⊃⌽⍵}⍣≡
 
ngn
@Adám yes
probably not the most efficient... just the first i thought of
off-topic: i really need to invest some time in making a vim shortcut for "copy current line as a markdown-formatted tio link"
 
10:02 AM
@ngn is expensive and unnecessarily compares all elements over and over. Better would be (⊢,⊢(∊⍨↓⊢)10|1+⊢/)⍣≡
 
ngn
@Adám yeah, that's better. or you could append to a global and at each step check if the new element is already there
 
 
1 hour later…
11:11 AM
@Adám Wouldn't it be better (also shorter) to use dyadic ?
 
@H.PWiz Ah, yes. Nice.
 
 
3 hours later…
2:34 PM
This week we bring you the final set of videos from Dyalog '18 - you can find the introductory blog post with links to the videos at https://www.dyalog.com/blog/2019/01/dyalog-18-videos-final-week/ We hope you have enjoyed watching them!
 
 
2 hours later…
4:35 PM
Hey guys. I need to filter a vector to remove everything from it that's not in ⎕A,819⌶⎕A. I've tried using , but it removes duplicates and I need it not to do that.
Does anyone know a golfy way to do it?
 
@J.Sallé 'helLo WoRlD'(⊣~~)⎕A?
(of course replacing ⎕A with ⎕A,819⌶⎕A; hope i understood what you wanted correctly)
oh 'Hello, World!'∩⎕A,819⌶⎕A works fine. annoyingly does different stuff based on the order of its arguments, and you need the filterers to be so isn't deduplicated
 
Oh god
I'll need to dfn that then
 
@J.Sallé shouldn't just (⎕A,819⌶⎕A)∩⍨ work fine?
 
Since the argument is what's to be filtered
Maybe, lemme check
 
@dzaima missing :P
 
4:42 PM
or ∩∘(⎕A,819⌶⎕A)
 
@dzaima that works
It's really weird that it deduplicates one way and not the other
 
@J.Sallé though your use-case has given me a reason to think it doing that isn't extremely horrible
 
Oh no I'd never argue it's horrible. It's just something I wouldn't have thought of
 
@J.Sallé I did argue it was horrible IIRC though
 
@dzaima You did say annoying
 
4:46 PM
@J.Sallé i meant before in this chatroom ages ago, not right now
 
Oh I see
 
so there's finally an answer to this question :P (though i can't seem to find my complaining about it ._.)
 
Hm, can someone explain why I get a rank error when trying to {⍋⍺}⌸'String'?
 
ngn
5:04 PM
@J.Sallé for the same reason ⍋'a' is a rank error
 
@ngn is not a scalar though
it's a vector of chars
I don't get the difference between doing {⍋⍺}⌸'String' and just ⍋'String' in this case, since {⍺}⌸'String' is 'String'
 
@J.Sallé is scalar though, executes ⍺⍺ for every unique item in
 
Well then I'm bamboozled
 
but... why would you want to grade a char up
 
I want to grade a char vector up
 
5:11 PM
so just use ?
 
@J.Sallé you know how {⍺,≢⍵}⌸'mississippi' is the regular way of counting characters in a vector? That clearly shows that s of the operand are elements of the right argument
 
@EriktheOutgolfer can't
 
i smell xy problem
 
why? is literally the Grade Up primitive
 
Unless I can sort it beforehand
I'll try something
 
5:13 PM
sort it beforehand? yeah, what dzaima said...
 
Yeah, can't sort it beforehand
 
what are you trying to do?
 
what exactly are you trying to even do ._.
 
So unless I can sort the input it's gonna be annoying af
 
what is the output you expected of {⍋⍺}⌸'String'?
 
5:17 PM
@dzaima what I actually wanted was {⍺[⍋⍺]}⌸'String'
But then I stumbled upon the rank error
 
@J.Sallé what would you expect the output of that to be then?
 
@dzaima same as 'String'[⍋'String']
 
@J.Sallé then why the hell are you using .........
the whole point of is to do specific things for groups of equal items of the right argument, and nothing to the whole of it
 
@dzaima I need that to count the number of repeating characters
and I'll use both and from so I thought it'd be handy
I'll need to rearrange a bunch of stuff
 
so put the code for that in 's ⍺⍺, not
 
5:22 PM
I just put the whole thing inside another dfn so I can access the argument as
 
hm... maybe we could see what you currently have?
 
I'm not even sure if is gonna help me much here, tbh. I just noticed that the specs changed
Now I need to "Group letters ignoring case. In the output, use the case of the last occurrence in the input". I don't think it changed, it was just reworded.
 
yeah, the challenge was unclear
yeah, Dennis's edit
 
@J.Sallé OP doesn't seem to have had any influence on the edit either
 
That's gonna be a pain to do now that I think of it
@dzaima Yeah I just read TNB
They reworded it to make it more clear
 
5:33 PM
hm... actually, one thing is still unclear
Can a letter appear more than 9 times? — Shaggy 10 hours ago
 
 
2 hours later…
7:04 PM
@dzaima with that, continued fraction is a simple ⌊(÷1|)⍡10
while that is a tiny bit obscure, nothing i could come up with was as simple and to the point as that
this also works ((⌊({÷1|⍵}\10∘⍴)) in Dyalog, but that's O(n²)), but it's obviously abusing scans ability to just ignore everything but one element
hmm, should I exclude tokenizing time between executions of ⎕HTIME/⎕TIME?
 
7:29 PM
oh the impact of tokenizing is way less than i would've guessed ._.
 
Yeah I was about to ask you if the impact was noticeable at all
tokenizing is usually not very costly in my experience
 
@J.Sallé i guess i kind of thought it'd have about as much impact as the operator & function & train binding "regex" mess, but tokenizing is way way simpler :|
for ⌊(÷1|)⍡10⊢○1 which takes ~34000ns on average, tokenizing gives ±900ns variance (0.034ms, ±0.0009ms converted)
*not ±; 34000 is average of both, 900ns is tokenizing included - not included
 
ngn
7:45 PM
@dzaima i include tokenization/parsing/compilation in \t:1234 expr, but i do that only once, so it shouldn't matter
 
@ngn hmm, i'd consider that to be worse than both options, as that gives a slight, constant difference between different timing amounts, but you're right, it shouldn't matter
 
ngn
@dzaima we have that problem anyway. the first time you evaluate an expression it has to warm up the caches, so the first execution is always slower
 
how would I do 2f/ from APL in J?
 
@ngn right, that's always gonna be a problem though. to try to counter things like that that i did 2↓⎕time∘'⌊(÷1|)⍡10⊢○1'¨ 10⍴(10000 0)(10000 1)
 
how do I use sharplot?
 
7:59 PM
oh ive completely forgotten that i've made every Obj (superclass of anything storable in variables) have a pointless string repr field.. it's used only for function string representations but that really should be a (virtual) method :|
 
@nathanrogers sharpplot.com/Languages.htm should help. Check under Dyalog APL
@dzaima wouldn't that be .toString()?
 
@J.Sallé toString is, annyingly, a separate thing. repr on +∘÷/ is /, toString is +∘÷/
 
Ah, I see.
 
argh i'd like to make a way for me to have optimized dyadic non-all-number functions, but that'd require copying this mess to another function and adding even more to it
 
ngn
8:24 PM
@dzaima when i'm timing stuff, i simply run \t or \t:n multiple times by hand, and ignore the first one
 
@ngn that's what i did too, until i needed to get down to 900ns precision
 
ngn
@dzaima don't you have the equivalent of \t:n (timing with a specified number of iterations)?
 
@ngn yes, but that varies a lot if manually executed many times. it's magic so i may just be imagining things though
i just don't want the processor to have any time to cool down i guess if that's even a thing
probably timing each execution independently and doing some statistics on the individual results would help, but i'm too lazy to do maths ¯\_(ツ)_/¯
 
ngn
i measure elapsed time in ms. if something runs too fast, i increase array sizes in the test until it gets to execute in 1 or 2s. if the test uses too much memory, i decrease the sizes and increase the number of iterations instead
@dzaima i think it is. i've seen "thermal management" or something in bioses
or "cpu frequency scaling"
 
@ngn timing tokenizing requires the payload to be relatively very quick. For pretty much every other speed test before this I've always done n ⎕htime¨ "p1" "p2" manually a couple times
 
ngn
8:36 PM
@dzaima too complicated... why bother
 
@ngn GC, but exactly
 
ngn
if you do multiple iterations and measure total elapsed time, their differences should average out
 
@ngn java timings never average out though
I'm pretty sure that if i speed-tested the same code over a full day twice, there'd still be a 1% difference :p
 
ngn
with c i get a confidence interval of +/- a few percent
so knowing how fast your java code runs down to 1% is pretty precise
 
huh, this actually converged to a somewhat concrete value. took a minute to run though
 
 
1 hour later…
10:11 PM
should 1='a' error because of type mismatch? if 'a'<'b', what should 'a'<1 do?
 

« first day (723 days earlier)      last day (1938 days later) »