« first day (635 days earlier)      last day (2014 days later) » 

10:25 AM
0
Q: Waiting between GUI events

August KarlstromI'm trying to write a test for a graphical component in Dyalog APL which will simulate button clicks which open new windows and keystrokes for filling in form fields. My first approach was to simply write a sequence of ⎕NQ statements for enqueuing events: ⎕NQ '#.foo.barButton' 'Select' ⍝ open...

 
 
1 hour later…
11:45 AM
0
Q: Why do I get this indexing error with string vector?

zeynelI'm studying APL from here. Why am I getting this syntax error? 'computer' [ 1 2 3 ] ← 'COM' SYNTAX ERROR 'computer'[1 2 3]←'COM' ^ But if I save 'computer' in a variable I don't get the error: T ← 'computer' T computer T[1 2 3] ← 'COM' T COMputer Wh...

 
 
2 hours later…
1:48 PM
{10=(¯1↑⍵)+10|(⌈/+/@(n-1)⊢⍵)+⌈/3×+/@(n←2×⍳6)⊢⍵} (takes a vector of digits as input) any clear golfs you guys can see here? I'm still checking if all the parenthesis are necessary
{10=¯1↑⍵+⍨10|⌈/+/@(n-1)⊢⍵+⌈/3×+/@(n←2×⍳6)⊢⍵} removed the redundant parens
 
+⍨?
 
I usually substitute stuff in parens for op+, didn't actually check to see if it was necessary
already fixed*
I'm not even sure if this is the best approach, but I can't figure out a better way to split the argument into even and odd indices
 
+/@ what
 
@dzaima gotta sum every digit in odd indices, multiply by 3 and sum with every digit in even indices
 
what's the input length? will everything be positive numbers?
 
1:56 PM
13 positive numbers, yes
the sum on the odd indices doesn't include the last one
 
you sure the sum of even indices will always be bigger than the biggest odd number?
 
Huh, that's a good question. I don't think so, actually
there are no test cases so I didn't think of that
 
I'll give you {{⍵+⍺×3}/⌈/⍉7 2⍴⍵,0} to go off of since I have no idea what you're doing
 
ngn
is this for the barcode challenge?
 
@ngn yes
@dzaima that helped a lot
got this {10=¯1↑⍵+{10|⍺+⍵×3}/+/¨↓⍉6 2⍴⍵}
 
ngn
2:07 PM
the barcode algorithm looks to me like a complicated way to describe +.× with 1 3 1 3...1
 
{0=10|⊃⌽⍵+{⍺+3×⍵}/+⌿6 2⍴⍵}
 
@dzaima huh. TIL +/¨ ←→ +⌿
or not
 
@J.Sallé more like +⌿ ←→ ⍉+/, but I didn't know that, I just guessed things :p
 
ah the ↓⍉ is no longer there, I see it now
 
ngn
+⌿ ←→ +/[⎕io], it's called "first axis reduce"
 
2:10 PM
@ngn again, the /[] notation is way more foreign to me than / & :p
@ngn oh wow {0=10|⍵+.×13⍴1 3}
 
@dzaima LOL does that really work?
 
@J.Sallé seems to pass the test-cases
 
well that's anticlimactic
 
for those who hate . (e.g. me), {0=10|+/⍵×13⍴1 3} also works
 
ngn
@dzaima +.× is train-friendly
0=10|⊢+.×1 3⍴⍨≢
 
2:17 PM
@ngn I got so close to this
 
@ngn oh right, damn you schizophrenia!
 
I was trying really hard to trainify that
 
@ngn oh yay that works in my apl :D
 
ngn
oh... I should have waited before I post this, sorry
 
nah, don't worry hahahah
I'll just blatantly steal it ⍨
 
ngn
2:19 PM
@J.Sallé fine by me :)
@J.Sallé i can make it even shorter
 
@ngn I just posted the answer and saw the question's been dupe-hammered
but go for it, I'd like to see that
 
ngn
0=10|2⊥+/,¯1⊥-
 
okay that's sorcery
 
^
 
ngn
i'll try to explain in a moment... hang on
 
2:33 PM
I surely hope so, I can already see people sharpening the pitchforks and lightning the torches
 
ngn
:D
1 3 1 3 ... 1 ←→ (2-1)(2+1)(2-1)(2+1)...(2-1)
 
oh god -1st base is so wonderful
 
ngn
←→ (2 × +/⍵) - ⍵[0]+(-⍵[1])+⍵[2]+(-⍵[3])+...
←→ (2×+/⍵) - ¯1⊥⍵ ⍝ <- the beautiful bit :)
←→ (2×+/⍵) + ¯1⊥-⍵
and then it's trivial to rewrite (2×A)+B as 2⊥A,B (A and B being scalars)
hm... would it be shorter if we use -/ instead of ¯1⊥?
0=10|-/-⍨2×+/
 
would 0=10|+/+2×-/ work or are the test-cases just nice?
 
ngn
@dzaima that looks wrong to me
 
2:46 PM
@ngn it does to me too, but is passes the test-cases
 
@ngn base -1. APL is good.
 
ngn
0=10|+/++/--/ ⍝ same length as before but more fun :)
 
@ngn new BF flavour!
BrainAPL
 
@dzaima it's passed like 12 random test-cases I gave it
 
ngn
⋄ f←0=10|+/++/--/ ⋄ g←0=10|+/+2×-/ ⋄ ⎕←∧/(f≡g)⍤1?1e6 13⍴10
 
2:54 PM
@ngn
1
 
ngn
@dzaima ^ it passed a million
 
BrainAPL works!
(on a side note, SE.chat needs emotes)
 
ngn
@dzaima so, your expression effectively does inner product with (1+2)(1-2)(1+2)(1-2)... ←→ 3 ¯1 3 ¯1... ←→ 3 9 3 9... (mod 10) ←→ 3 × (1 3 1 3...). we're only interested when that is 0 (mod 10), so that's why it's correct
in other words, you outgolfed me :) i don't think the expression can be shrunk any further
 
@ngn I didn't really outgolf, I just wrote incorrect code that you proved to be correct :p
 
3:13 PM
@dzaima I wish my boss worked like that. Unfortunately I write incorrect code which he then proves is incorrect.
 
oh ಠ_ಠ I'm parsing a chain of dyadic ops right-to-left
oh wow that was an easy fix
 
It's kinda weird because you read stuff right to left but dops need to be executed left to right and I get like ⍨
 
and with that, I seem to have implemented @. Wasn't nearly as scary as I expected it to be
 
ngn
@dzaima you need automated tests
 
@ngn the problem with that is that then I'd have to write tests. But yeah, you're probably right
I really like what I did with Canvas and making its docs examples its tests, but that isn't gonna work for this
 
ngn
3:27 PM
@dzaima you write them in the repl anyway :) so why not collect them in a file
 
@ngn I don't.. test stuff really, ever.
 
@dzaima yeah, who wants to have the docs' examples be misleading?
:P
 
or write automated automated-test creators which then perform the automated tests
 
@Cowsquack and write automatic tests for the automatic automatic test generator
 
Gotta love them loops
 
 
3 hours later…
@dzaima looks good
 
CMC (from that): given an array x1 y1 x2 y2 sort them so x1 < x2 & y1 < y2
 
ngn
@dzaima wow, that looks cool! did you push it to the repo?
 
@ngn Not yet. I want the thing to have half-concrete syntax before publishing it (though I can be persuaded otherwise)
 
okay guys, so: If I have a function f and an argument , how do I run f times, feeding the result of f onto itself? I'm trying to use and failing miserably.
 
6:27 PM
@J.Sallé it should be just f⍣⍵ ⊢ start
 
Huh I must be doing something incredibly stupid then
Lemme check again
 
@J.Sallé first thought: not separating from the starting value
 
ngn
@dzaima i was just asking, no rush
 
@ngn I've spent some time thinking about 0j3⊥⊢, but summing the imaginary and real parts is too expensive
 
@H.PWiz oh god what
 
6:33 PM
@dzaima or just sort them?
 
@dzaima You can use (13⍴3 ¯3)⊥⊢, which is the same as 9 11+.○0j3⊥⊢
 
@EriktheOutgolfer you have to keep the order x y x y
 
@dzaima oh, so stably sort them
 
@EriktheOutgolfer no? 1 5 2 6 should stay 1 5 2 6, not get sorted
 
@dzaima yeah, the order is preserved, that's what stable sort means
 
6:36 PM
@EriktheOutgolfer stable sort only makes sense for things where two equal objects can be different
the cmc's basically "sort items 1 & 3 and 2 & 4 separately"
 
yeah, that's not really a sort
 
exactly
 
might've found another way to do what I was trying, just need to manage to make a numbers vector into a string or something
(as in 2 3 4 → '234')
∊⍕¨ works I guess
 
@J.Sallé 10⊥2 3 4?
 
@Adám better
 
6:51 PM
When people first learn about and they often think that those must be the least useful functions; so specific…
 
Indeed
also what I was trying didn't work D:
 
ngn
@H.PWiz neat idea
 
@Adám can you give me a lil' hand here? I need to repeat the inner function from {0=⍵:0⋄{4 3 3 5 4 4 3 5 5 4[⍎¨⍕⍵]}}<arg> arg times, starting at 0 and feeding the result of the inner function for the next iteration (basically f(f...(f(0))) )
So {0=⍵:0⋄{4 3 3 5 4 4 3 5 5 4[⍎¨⍕⍵]}}3 should return 13 (because f(0) = 4 + f(1) = 7 + f(2) = 10 + f(3) = 13)
 
{...}⍣arg ⊢ 0 should work
 
@dzaima But gives me 4
 
7:00 PM
I've tried doing {0=⍵:0⋄{4 3 3 5 4 4 3 5 5 4[⍎¨⍕⍵]}⍣⍵⊢0}3 but it just returns 4 all the time
actually wait a sec
 
@J.Sallé that means your code is bad
 
@J.Sallé Btw, is 4 3 3 5 4 4 3 5 5 4 is (⎕a⍳'EDDFEEDFFE')
 
@dzaima that's not exactly news though >.> everything I post here is bad
 
@J.Sallé So not true
 
>.> I always need help doing stuff though
 
7:02 PM
@Adám ⍎¨⍕4335443554
 
Btw I forgot I need to sum the results so the function is actually {+/(⎕a⍳'EDDFEEDFFE')[⍎¨⍕⍵]}
 
@dzaima for which part from that?
 
I know what's wrong, I think
The function needs to use as argument 0, 04, 048, 04813, 0481321... etc
04 breaks though because it's interpreted as 4.
well all of those will break, obviously
 
7:17 PM
@Cowsquack my in function is horrible and I needed to convert all rectangles to that format so they would register correctly no matter which direction the rectangle was made (done by the sort function)
 
@dzaima if the two coords are given as two separate args, ,>⊖,[.5]
actually in LM.r, you have sort LM.s, P5.mpos, so you can place it in between
 
@Cowsquack so x1 y1 (,>⊖,[0.5]) x2 y2? That doesn't seem to be working for me
@Cowsquack I'm not asking the CMC for that, as I don't expect anyone to know my APLs syntax (e.g. ,[...] doesn't exist, but that doesn't matter here)
 
 
3 hours later…
10:17 PM
CMP: P5.fill 'FFFFFF' or P5.fill←'FFFFFF' for setting the filling color to #FFFFFF
 
@dzaima How would you query it if a fn?
 
@Adám oh, didn't think about querying it. I don't have any idea how to implement querying in Processing though ¯\_(ツ)_/¯
right, set makes more sense anyway
 
@Cowsquack It's not that any of those operations you gave are inherently inefficient, it's about how they map to the machine in the interpreter, and how easy or hard it is to convert an expression to good machine code. Sometimes, there's a very hard line that you can draw (such as the use of Each when you don't need it), but other times that's more subtle.
The more you're willing to let the system work on your code (through magic compilation or super-compilation) the more your code will suddenly become efficient, but the less you'll be able to predict whether it will do so without vast amounts of additional knowledge.
Thus, the stylistic metric is for simpler, more direct code, since that's what the interpreter can make fast.
It's also easier to read.
Understanding why it is slow or fast is a simple matter of understanding how the primitives map to the hardware and memory.
@Adám That BST code is pretty fun.
 
@arcfide :-D
 
I don't think I can do better than translating the Jelly code though.
 
10:28 PM
@dzaima looks like the color is stored as protected fields, which I don't have access to. Probably not worth it making my own storage for the fill color, but I'll switch it to G.fill←
 
@arcfide Usually so; Jelly is basically left-to-right golfing J on a K array model.
 
Well, I meant the actual algorithm, not so much the golfing. Checking trigrams was about what I was zeroing in on anyways before I looked at the solutions.
Actually, it's not trigrams, it's 3-sequences.
Those aren't technically the same thing.
 
 
1 hour later…
ngn
11:54 PM
@arcfide if you're interested: question about call/cc in another chat room
 

« first day (635 days earlier)      last day (2014 days later) »