4:38 AM

4:48 AM
@Adám by finger count, new solution is around 5 seconds, and old solution around 18
The indmin function isn't returning the results I want, as I want to return specific colors base on what was hit, though that's probably already solved I just need to map the results some new way

5:13 AM
actually, much easier than I thought`colors[(Pcs Scs 0)[l]]`

1 hour later…
6:27 AM
@arcfide what do you think of `,\0 1 2`?

6:51 AM
@ngn how do you drop a dimension?
I have a shape 1 2 8 6 and I want to drop the 1
so that I have a shape 2 8 6

@nathanrogers reduction deletes a dimension. you could do `⊢⌿` for instance

@ngn i have a 2 8 6 and an 8 6
I would like to make a 3 8 6

@nathanrogers `⍺⍪↑,⊂⍵` ⍝ there may be a better way

7:20 AM
@nathanrogers `A286⍪A86`

when I have an 8 6 and an 8 6 it doesn't work
it creates a 16 6

@nathanrogers True, but that wasn't your question.

ok, how do I extend joining 2 8x6 matrices such that I wind up with an additional leading dimension?
8x6 and 8x6 makes 2 8 6, a 2 8 6 and 2 8 6 makes 4 8 6

@nathanrogers For that you need `a,[¯0.5]b` or `↑a b`
@nathanrogers Those two operations are fundamentally different, as the first adds an axis, the second not.
@nathanrogers If you want a general solution (specific, actually) that handles both rank-2 and rank-3 args, use `{(⍺⍴⍨¯3↑1,⍴⍺)⍪(⍵⍴⍨¯3↑1,⍴⍵)}`
`{⍵⍴⍨¯3↑1,⍴⍵}{(⍺⍺ ⍺)⍪(⍺⍺ ⍵)}` is an alternative way to write that without code duplication, and in my extended APL, `⍪⍥{⍵⍴⍨¯3↑1,⍴⍵}`.

7:30 AM
@nathanrogers I can't see images on the train.

@nathanrogers I mean, the train blocks imgur. I'll just look later when I get to the office.

oh that's right other countries don't celebrate thanksgiving
I give thanks for the extra days off
`(2 3 4⍴⍳6){(⍺⍴⍨¯3↑1,⍴⍺)⍪(⍵⍴⍨¯3↑1,⍴⍵)}(2 3⍴⍳6)` or reverse args
I'm not getting something
(⍳2),[¯0.5](2 2⍴⍳4)
also not waht i expected

@nathanrogers The planes don't match; 3 4 vs 2 3!

oi derp
lol
thanks

7:35 AM
@nathanrogers Here you are pairing a rank-1 with a rank-2 and adding a new axis. Expect mess.
@nathanrogers `,[k]` requires otherwise conformity. `↑a b` will pad with the prototype of `a`.

3 hours later…
10:27 AM
@nathanrogers Remove `¨` from `indmin[3]`: `ds←inf@(≤∘0)⍵` for a significant speed-up. If you want even more speed, refactor your formulas to only use real numbers, as complex arithmetic is slow.

2 hours later…
12:19 PM
@dzaima I just added `⍮` and noticed a new idiomatic function: `↑⍤⍮` "rank-up". Monadically, it increases the rank by 1. Dyadically, it pairs the arguments along a new leading axis, e.g. two vectors become a matrix, and two matrices become a 3D array. The args have their ranks and shapes aligned appropriately. :-D

2 hours later…
2:07 PM
CMC: `0 0⍴' '`

2:21 PM
7 bytes :P

2:32 PM
@Quintec Uh, the CMC spec is 7 ⍨ I've got 4. Just discovered it today.
@Quintec Also, there is one obvious byte to save.

2:45 PM
@Adám i got 5: `0/⍪''` still trying...

@ngn Yup, I knew someone would find that one, but this one is… unusual. Think out of the box!

I get 3 for `0 0⍴⍬`, but still trying for `''`

@Adám Another 5 is `⊢⌸⍨''`

and another 5-byter `↑⊆⍨''`

3:07 PM

@ngn `⎕NL⍬`

`{0::⋄(0 0⍴'')≡⍎∊'⎕'⍵'⍬':⎕←⍵}¨,∘.,⍨⎕a`
i guessed the general form of the solution and tried all `⎕XY` combinations

Hey guys, is it possible to set a recursive Dfn to sleep for some time before calling the recursion?

@ngn Ah yes, you don't know how to ask the interpreter which 2-letter ⎕-names it knows…
@J.Sallé Sure, `⍺∇⍵⊣⎕DL 3`

3:23 PM
@Adám oh nice that's what I needed. What does the DL stand for? Also, is 3 the time it'd sleep for?

@J.Sallé DeLay, and yes, time in seconds. It returns the actual elapsed time shyly.

Great, I think that's gonna work then

@ngn Secret feature ;-) The interpreter can do a lot of stuff we don't tell about.

@Adám another thing, is there a way to insert a linefeed in a string other than `⎕TC` (Mastering Dyalog APL says that's obsolete but I can't find an alternative)?

3:32 PM
@J.Sallé `⎕ucs 10` is what I've seen used everywhere

@dzaima Oh nice, thanks!

usually as `nl←⎕UCS 10⋄...` so you don't need to spam parenthesis

indeed

Maybe even `nl←{⍺←⊢ ⋄ ⍺,(⎕UCS 10),⍵}` so you can write `'Abc'nl'def'nl'ghi.'`

I'll only need it once, so just doing `,(⎕UCS 10),` works fine for me

1 hour later…
4:51 PM
@Adám can I have a while-like statement in a Dfn? Basically I need my function to call itself recursively while `⍵≤5`, but I also need it to output some text, so the usual `cond:true⋄false` statement doesn't support that afaik
or should I just make an inner function to do that?

@J.Sallé Can you reverse the condition to allow you multiple statements if true?

@Adám I think I can. You mean do something like `⍵≥5` instead of `≤`?
It'll add a byte or two but it's not a big deal

@J.Sallé No, `⍵>5`

I need that 5 though so I'll need either `⎕IO←0` or `⍵>6`

@J.Sallé Alternatively, you can use `⊣` instead of `⋄` (and reverse order of statements)

5:01 PM
That might also work, lemme try it

@J.Sallé I don't get it.

@Adám I'll explain, just a sec
Okay so, I'm trying to solve this challenge. Basically, I need to print a fixed string every 2 seconds 5 times, and each time the string needs to be followed by a linefeed and a (randomly selected) `.` or `!`.
So basically it'll print `string\n` for tick 0, then `string\n.`, then `string\n.!` and so on
Currently I've got `{⍵≤5:'Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:',(⎕UCS 10),'.!'[?⍵⍴2]⋄∇(⍵+1)}` but it'll obviously only print once
All I need is to print that 6 times (with `⍵=1-⍨⍳6`)

5:21 PM
@J.Sallé Sorry, got distracted.

No problem, this is definitely less important than whatever you were doing hahahah

@J.Sallé Doesn't this work?:
`⋄ {⎕←'Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:',(⎕UCS 10),'.!'[?⍵⍴2]}¨⍳6`

```@Adám
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.!
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
!!!
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
!.!.
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.!!..
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
!.!!.!```

@Adám nope, there has to be a delay of 2 seconds between outputs (and something else I just noted, the `.!` must stay in the same order)
that second part will be a pain

@J.Sallé Sure, but you can put in a `⎕DL` inside the dfn.

5:26 PM
also the first message has nothing after the linefeed

@J.Sallé What order do you mean?
@J.Sallé `⎕IO←0`
@J.Sallé For code golf, you do want the deprecated `,⎕TC[2],` instead of `(⎕UCS 10)` or even use `⎕ML←3` and use `,2↓⎕TC,`

@Adám I was about to mention that. If the second message has a `.` after the linefeed, the third needs to have that same dot in that position

Getting off train. Later!

No problem! I'll probably finish this up tomorrow

2 hours later…
7:37 PM
holy shit yeah that is a significant speed up! @Adám

Nov 6 at 6:17, by dzaima
@nathanrogers a simple way to score the speed of an APL program is count the number of `¨`. The more, the worse it'll be.

But I mean, from 5 seconds to almost instant
That's crazy

@nathanrogers Hey, can you count how many `¨` were in your original code, and how many are there now?

@Adám unfortunately as far as complex arithmetic, that's only due to the quadratic formula. The sphere detection formula returns a complex number if it doesn't intersect. Unless there's an alternative sphere intersection formula, I don't know how to get rid of that

@nathanrogers OK, but anyway, it is "fast enough" now to be workable, right?

7:41 PM
yeah, it's almost instant
even at higher resolutions
with multiple objects

@nathanrogers the power of APL when you use it well. :D

There weren't many ¨'s there, but there was a lot going on in the ∘. function, now the ∘. is just a simple multiplication, and the new data structure makes it really fast
I had 3 in the original ¨ and 3 ¨ now, ¨ plane ¨sphere and ¨width and height
I did a good job of keeping @dzaima in mind when making my first go :P
but I didn't know about "arrays", and certainly hadn't used anything higher dimensional to solve any problems

¨-)

so this was a crazy good learning experience

@nathanrogers Good. See? You are getting there.

7:45 PM
4000 by 2000 resolution took 2 seconds
that's crazy

@nathanrogers How long does it take in C++?

let me see

@nathanrogers I still haven't begun touching 3D+ arrays, so that's one thing you're more experienced at than me :p

5 seconds

@dzaima We have customers that threaten to give APL up if we don't increase maxrank.

7:47 PM

@nathanrogers Heh, interpreted APL beats compiled C++!

this is really good news. uncompiled, this is really fast

@nathanrogers And that C++ code is well written, by somebody who knows their stuff?

I was using this as sort of a test bed to see if graphical APL would be feasible, and I guess now I know that it is
He's worked on the Witness with johnathan blow, so I'm assuming yes?
I've watched a lot of his content, and he really knows C and the Win32 API for graphical programming inside and out.
He didn't optimize anything, so maybe optimized it would be faster and I'd have to actually time things for real

@nathanrogers Well, that kind-of proves my oft-repeated claim that APL often can beat carefully hand-written C/C++ despite APL being written in C/C++.
@nathanrogers I wonder if co-dfns would gain you even more speed.

7:50 PM
I'm using codfns for the display, but I don't know how to namespace, or compile things
at 4k resolution, the new one takes 2-3 seconds, the old one takes 45 seconds
incredible
@Adám who is the guy you spoke to about my original version?

@nathanrogers Marshall
@nathanrogers how to namespace?

yes
I don't understand Dyalog project structure, and namespaces are really wierd. I've tried to make namespaces and then load them, but then it says "not a namesapce"
so I really don't get it

@nathanrogers You may want to have a look at Lesson 16.

@nathanrogers To save and load them, look at the end of Lesson 28.

7:59 PM
@Adám did you catch my question from last night about how to drop specific ranks?

@nathanrogers Uh, no, I think I missed it. Can you link me?

@nathanrogers didn't ngn already answer with `⊢/` (or `⊢/[dim]`)?

13 hours ago, by nathan rogers
@ngn how do you drop a dimension?
Just wondering if there was a more standard solution, as I seem to recall a discussion about a specific operator which dropped specific ranks
but that might have been a misunderstanding on my part

@nathanrogers I don't think there's anything better than `⊢⌿`
dropping a rank if it's exactly one is pretty specific (though I think a built-in type of thing that errors if it's not one would be helpful)

@nathanrogers I saw that, but ngn answered right. If you want to drop dimension `k`, just do `⊢/[k]`

8:02 PM
ah
there's something goofy going on with the spheres, because each sphere, if hit, will return 2 values
2 matrices, so get the min to get the closest between them
but then if multiple spheres intersect on the same point, I get back multiple lists

@nathanrogers Doesn't every ray that hits a sphere have an entry point and an exit point?

so I was getting back n x 1 x h x w shapes
yes, but I onlly get the min of the sphere
so the closest hit point
say 3 spheres intersect on the same point, 3 1 h w, would be the shape
so I did ⊢⌿↑⍉
perhaps just ⊢⌿[1]

@dzaima oh right something stupid like `{÷}⌿` works (as typing `⎕signal` is way too much work) :P

@dzaima That's actually pretty clever.

`mindex Pds {(⍺⍴⍨¯3↑1,⍴⍺)⍪(⍵⍴⍨¯3↑1,⍴⍵)} ⊢⌿↑⍉Sds`
using your 3d specific append from yesterday
@dzaima I don't get it

8:09 PM
@dzaima Hey, you finally found a use for a niladic derived function! (Do you know how to make one?

@Adám `2∘+∘3⌿`? :D

@dzaima Save 2 bytes: `2∘3⌿` (!)

@Adám oh I thought that'd be a syntax error all the time, cuz i did `2 . 3` at first

@nathanrogers Never mind, we're being silly.
@dzaima `.` is special :-( `2⍣3/` works too and so too any normal dyadic op.

8:12 PM
relatedly, a thing I'd really like in every language to be is a syntactical construct for "TODO" that errors upon getting reached

@dzaima Syntactic construct? We tend to write `∘∘∘` or `...`

@Adám `...⌿1 2 3⍴0` errors immediately though

Wat?:
`⍞←0⍣0/1 2 3`

`@Adám 3`

@dzaima Yes, as a I said, `.` is special (due to nss and `∘.` and `2.3`)

8:14 PM
@Adám so does `∘∘∘⌿1 2 3⍴0`

@dzaima Yes, because that isn't a valid derived fn.

but yeah, that expression is a very special case of requiring erroring

@dzaima Sure, but the parser doesn't even manage to make sense of anything. `2∘3` is perfectly OK syntactically.
@DyalogAPL Ah, I get it; you don't care about the left operand if the right operand is 0.

@Adám heh, makes sense why that'd happen but still feels strange :p

Conditional inline syntax error: `0⍣cond⊢`

8:18 PM
:D

However, I still think a bunch of operators which only take functions as left operand should be extended to treat an array left operand as `A⊣⊢`
Then you could conditionally replace a value by another with `replacement⍣condition⊢normal`
@dzaima Hah, I found a shorter (albeit even more obscure) one: `0&/`

@Adám heh, `&/` was one of the first things I tried, forgetting that it's an operator

@dzaima This of course works with any monadic operator which doesn't take an array operand (that's all of them, no?)

@Adám `⌶` is an exception

@dzaima Ah yes, it only takes a simple scalar positive int.