1:02 AM
what's the shortcut in )ed to align the comments? (if there is one)

4 hours later…
5:28 AM
@rak1507 I don't think there is one by default. Configure the keyboard shortcut for action <AC>:

6:26 AM
I have two arrays with the same dimensions, call them A and B, and a third boolean array, C. I want to create an output array, where the values from come from either A or B depending on whether C is true of false. So for example, if A←1 2 3 4 ⋄ B←11 22 33 44 ⋄ C←0 0 1 1`, I want the result to be `1 2 33 44`.
What is the nicest way to do this?

@EliasMårtenson The first thing that comes to mind is `(A,[0.5]B)[↓(1+C),⍪⍳≢C]`
```      A←1 2 3 4 ⋄ B←11 22 33 44 ⋄ C←0 0 1 1 ⋄ (A,[0.5]B)[↓(1+C),⍪⍳≢C]
1 2 33 44```

I did this for a one-dimensional array: `0 0⍉(A,[0.5]B)[;C]`

haven't played around with dyadic transpose yet

The problem is that I need a generic solution.
@Razetime It's the first time I used it. :-)

generic, meaning?

6:35 AM
That said, KAP doesn't support the `0 0` form, so I still need to find a better way.
@Razetime One that works regardless of dimensionality of the arrays.
That said, I guess I could do: (⍴A) ⍴ 0 0⍉((,A),[0.5],B)[;,C]

@EliasMårtenson `(C/⍥,B)@{C}A`

OK, that exposed me to @ and ⍥. Please allow me to read up on them first.

Yet another need for Under (`⍢`): `B⊣⍢(C/⍥,⊢)A` Try it online!

This goes into APLcart now.

6:48 AM

@Adám I can't find documentation for ⍢ in the dyalog documentation.

Because it hasn't been implemented yet.

I see. :-)
Is there a writeup on it somewhere?

`⍢` is basically a generalisation of the `@f` and `@A`
@EliasMårtenson BQN
If I had been quicker, I'd have protested adding `@` back in 16.0 and instead argued that we should add the more general form.

@EliasMårtenson dzaima/APL :)

7:01 AM
@EliasMårtenson Btw, GNU APL has an ad-hoc syntax for this, namely `A⊢[C]B` but I do not recommend adding such obscenities to the language.
@dzaima Huh, I didn't know about that.
@EliasMårtenson `C⊃¨A,⍥⊂¨B` works too, of course, but super-inefficient.
`C⌷⍤0 1⊢A,⍤0⊢B` is better.

@Adám about `%` at all or that it works on high rank arrays? (i've mentioned `%` somewhat recently, but i had no clue if i had actually bothered to implement it for high rank)

at all

7:20 AM
@Adám Actually, I considered adding something like that (as a library call, not a language extension)

So, say I have an array `A`, and it's got elements 1 2 3 4 5 6
and I have a function f
I want to get `1,(1 f 2),2,(2 f 3),3,(3 f 4),4,(4 f 5)` and so on

@Adám Actually, this one would be efficient in KAP, if I understand the code correctly.

@dzaima it'd be a good idea to remove a ton of `NYIs` in the repo

@Razetime `⊃,/2f{⍺(⊣,⍺⍺,⊢)⍵}/A`

7:27 AM
side note: this isn't for golfing

@Razetime `s/NYI/NGBI/g` (not gonna be implemented)? :P

@dzaima oh come on there's so many things implemented that are marked NYI
like `?` is marked NYI

oh you mean in docs/chars.txt

yes indeed

yeah that's just plain outdated all around

7:29 AM
that's what i generally refer to when trying something

ok i'll try to update that

@Adám `⊃,/2(⊣,f,⊢)/A` simpler?

@Razetime Yes, of course. D'oh.

@Adám i'm quite happy with `C⊃¨A,⍥⊂¨B` being 2x faster in dzaima/APL
(as dzaima/APL would be, and of course is slower for everything else)

7:34 AM
@Adám this gives `1,(1 f 2),2,2...` , I don't want repeated elements

@dzaima (that's for 10000 item arrays. for larger ones they're more similar, but dzaima/APL still can be like 30% faster)

@Razetime `⊃,/2(⊣,f)/A` then.

hm nice
@Adám but this eats the last element

7:51 AM
@Razetime Sure, but trivial to append.

aghh

No, that's an invalid train ;-)

not in dzaima/APL :)

8:21 AM
@dzaima pushed

2 hours later…
10:06 AM
@Adalynn welcome back. yeah for sure you didn't miss out on any changes to se chat

10:46 AM
What's a good way to zero the lower triangular of a (square, boolean) matrix?

you could do a boolean and with ∘.<⍨⍳≢m

@xpqz Just remember that ∘.f with `f` one of `< ≤ ≥ >` is your friend when you want `...` triangular matrix `...`.

@xpqz aplcart.info?q=extract%20upper ― all add some synonyms.

`(∘.<⍨∘⍳∘≢×⊢)`

10:53 AM
@RGS beautiful

@rak1507 That only works on Booleans, though. (But I assume you meant to prefer a dfn.)

@Adám he specified that it was a boolean matrix

Coding with generality is always (?) a good thing.

Sure, just that the APLcart entry (and RGS's equivalent) is more general.

fair enough

10:57 AM
@Adám I did search dilligently on APL cart, but in a glass-half-empty way: zero triangular etc. But I think it would be nice if this showed on just 'triangular' as every other operation on triangulars seem to do.

@xpqz It does show on "triangular":

So it does; obscured from my vision by not thinking of it as "extracting the upper" but "wiping the lower" :?
My problem, not APLCart's.

I've added "zero out lower" now.

4 hours later…
2:48 PM
Ok, more array gymnastics: given a boolean rank 2 matrix A and Ys Xs, zero all elements on row Ys and col Xs in A, except A[Ys;Xs], and leaving all other elements as is. So given:
`3 3⍴1 0 1 0 0 1 1 1 1`
and 2 2, we should get
`3 3⍴1 0 0 0 0 0 0 0 1`
(⎕IO←0)
A chess rook, basically

{x y←⍵ ⋄ m←⍺ ⋄ (2⌷m)←0 ⋄ (2⌷[2]m)←0 ⋄ (⍵⌷m)←⍵⌷⍺ ⋄ m} horrible solution
{⍺∧1≠+/⍵=⍤1↑∘.,⍨⍳≢⍺}

@rak1507 You're on fire today. Nice.

having exams soon magically makes me productive in everything that isn't doing revision

4 hours later…
7:30 PM
fun

oh this was you

oh, I've discovered that before

well, this is the reverse

7:54 PM
```      r ← ⍤0 1
+r⍨ 1 2 3
2 3 4
3 4 5
4 5 6
r
┌─┬───┐
│⍤│0 1│
└─┴───┘
+r⍨ 1 2 3
0 0 0
0 0 0
0 0 0```
now this was unexpected

Same kind of thing, I suspect.

I assumed it would error but it's interesting that it doesn't

```      r←⍤0 1
+r⍨2 3
4 5
5 6
+r⍨4
8
r
0 1
┌─┘
⍤
+r⍨2 3
0 0
0 0
+r⍨4
VALUE ERROR
+r⍨4
∧```

weird

Again, it is the display that does it:
```      ]box off
Was ON
r←⍤0 1
+r⍨2 3
4 5
5 6
+r⍨4
8
r
⍤ 0 1
+r⍨2 3
4 5
5 6
+r⍨4
8```

8:02 PM
bc why wouldn't outputting have side effects lol

Dec 10 '20 at 11:40, by Adám
@rak1507 It is bug 17228 in the interpreter: When the interpreter needs to call a callback function to print something, it should create a `⎕OR`ed clone of the item to print and pass that, but instead it does an in-place `⎕OR`ing and so a side effect of printing with a callback is that the item that was printed changes from being a function to be a `⎕OR`.

ah

Fun with functions as first-class objects:
```      Apply←{⍵{⍺⍺⍵}⍺}
Minus←-
o←⎕or'Minus'
⍴o o o
3
4 Apply o
¯4```