3:54 AM
@Adám How might I do a summation, like this:
I realize I can use `+/` for the sum itself, but I'm not sure how to create the range and map it over a function.
Actually, I can create the range with `⍳`, but I'm still unsure about the mapping.

4:19 AM
Oh, silly me. The operations map to lists by themselves
So `+/((⍳11)-1)*2` works, but with an ugly amount of parens

3 hours later…
7:42 AM
@Pavel You can leave the 0 term out as 0=0², and remove parens using `⍨` (commute), i.e. `x*2` ←→ `2*⍨x`. Therefore, `+/2*⍨⍳10`. However, note that squaring is the same as self-multiplication `×⍨` (`⍨` is "selfie" when the derived function is applied monadically) so `+/×⍨⍳10`. If you want a function, for n instead of 10, then the shortest is `+/⍳×⍳` or `⍳+.×⍳` or `+.×⍨⍳`.

3 hours later…
10:58 AM
@ngn How do convert ascii points to letters in K? E.g. 65 → "A"

11:35 AM
@Adám huh? it does look like it sorts multidimensional arrays as in the examples I've posted above
also nested arrays don't have an order, so sort them based on what?
⎕←{⍵[⍋⍵]}(3 3⍴⍳27)[2 1 3;;]

```@EriktheOutgolfer

Rebuilding user command cache... done
Was OFF -trains=box -fns=off
⍎RANK ERROR
__field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''box on -fns=on -trains=tree''⊣enableSALT' ⋄ ⎕←{⍵[⍋⍵]}(3 3⍴⍳27)[2 1 3;;]
∧

Real time: 1.062 s
User time: 0.924 s
Sys. time: 0.044 s
CPU share: 91.17 %
Exit code: 0```

doesn't seem to be really a no-op?

@EriktheOutgolfer You have the wrong number of `;`s in brackets:
⎕←{⍵[⍋⍵;]}(3 3⍴⍳27)[2 1 3;]

```@Adám
1 2 3
4 5 6
7 8 9```

But you can avoid having to supply the right number of `;`s by using `⌷`:
⎕←{⍵⌷⍨⊂⍋⍵}(3 3⍴⍳27)[2 1 3;]

11:44 AM
```@Adám
1 2 3
4 5 6
7 8 9```

@Adám um that doesn't look like it works
it only returns 1-3, 4-6, 7-9

@EriktheOutgolfer How so?
@EriktheOutgolfer What did you expect?

@Adám I want a 3x3x3 array of [1..27]

@EriktheOutgolfer Then you're missing a 3:
⎕←(3 3 3⍴⍳27)[2 1 3;]

```@Adám

Rebuilding user command cache... done
Was OFF -trains=box -fns=off
⍎RANK ERROR
__field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''box on -fns=on -trains=tree''⊣enableSALT' ⋄ ⎕←(3 3 3⍴⍳27)[2 1 3;]
∧

Real time: 1.162 s
User time: 1.055 s
Sys. time: 0.046 s
CPU share: 94.67 %
Exit code: 0```

11:45 AM
Heh, and need two `;`:
⎕←(3 3 3⍴⍳27)[2 1 3;;]

```@Adám
10 11 12
13 14 15
16 17 18

1  2  3
4  5  6
7  8  9

19 20 21
22 23 24
25 26 27```

14 hours ago, by Erik the Outgolfer
⎕←{↑⍣r⊢(↑↓⍣(r←≢⍴⍵)⊢⍵)[⍋⍵]}(3 3 3⍴⍳27)[2 1 3;;]
@Adám are you referring to this?
looks like I have already put 3 3s in there...

@EriktheOutgolfer Yeah:
⎕←{↑⍣r⊢(↑↓⍣(r←≢⍴⍵)⊢⍵)[⍋⍵]}(3 3 3⍴⍳27)[2 1 3;;]

```@Adám
1  2  3
4  5  6
7  8  9

10 11 12
13 14 15
16 17 18

19 20 21
22 23 24
25 26 27```

⎕←{⍵⌷⍨⊂⍋⍵}(3 3 3⍴⍳27)[2 1 3;;]

11:46 AM
```@Adám
1  2  3
4  5  6
7  8  9

10 11 12
13 14 15
16 17 18

19 20 21
22 23 24
25 26 27```

@EriktheOutgolfer Do you not agree that `'ABC'` comes before `'DEF'`?

@Adám duh, I tried `⌷` too and it didn't work for me

@EriktheOutgolfer Always remember to enclose the indices.

hmm, anyways
@Adám well that would make sense
however
⎕←⍋'ABC' 'DEF'

```@EriktheOutgolfer

Rebuilding user command cache... done
Was OFF -trains=box -fns=off
⍎DOMAIN ERROR
__field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''box on -fns=on -trains=tree''⊣enableSALT' ⋄ ⎕←⍋'ABC' 'DEF'
∧

Real time: 1.358 s
User time: 1.254 s
Sys. time: 0.041 s
CPU share: 95.32 %
Exit code: 0```

11:48 AM
@EriktheOutgolfer Right, but I'm working on fixing this as we speak.
⎕←{⍵⌷⍨⊂⍋↑⍣≡⍵}'XYZ' 'ABC' 'DEF'

```@Adám
┌───┬───┬───┐
│ABC│DEF│XYZ│
└───┴───┴───┘```

@Adám hm, may fail with unprintables <32?
(32=space)

@EriktheOutgolfer I know. That's what I was working on. Spoke with CTO and CXO this morning…

I just suspect that becuase `' '` is the prototype used for such stuff

@EriktheOutgolfer Of course.

11:52 AM
@Adám ⍋ which supports nested (non-ragged) arrays, right?
and ⍒ similarly

@EriktheOutgolfer Even ragged ones. Already proposed by Roger. I'm just arguing about the space issue.
@EriktheOutgolfer Here, this works:
⎕←{⍵⌷⍨⊂⍋↑⍣≡⍵}'xyz'('abc',⎕UCS 9)'abc'

```@Adám
┌────┬───┬───┐
│abc	│abc│xyz│
└────┴───┴───┘```

@Adám :D woah what's that mess :p

⎕←{d←⍵ ⋄ (∊d)←⎕UCS@(0≠∘⊃0⍴⊂)∊d ⋄ ⍵⌷⍨⊂⍋↑⍣≡d}'xyz'('abc',⎕UCS 9)'abc'

```@Adám
┌───┬────┬───┐
│abc│abc	│xyz│
└───┴────┴───┘```

11:57 AM
@EriktheOutgolfer The second item has a trailing tab.

@Adám not completely fixed, since you actually need null (0x0) which is the minimum char
but still better than space :p

@EriktheOutgolfer True.
@EriktheOutgolfer Here, this works:
⎕←{d←⍵ ⋄ (∊d)←(1+⎕UCS)@(0≠∘⊃0⍴⊂)∊d ⋄ ⍋↑⍣≡d}'xyz'('abc',⎕UCS 0)'abc'

```@Adám
3 2 1```

(I removed the actual sorting, as you can't see a null. So this is just the grading.)

⎕←⎕UCS 0

12:00 PM
```@EriktheOutgolfer
```

why chat can't view nulls ;_;

@EriktheOutgolfer Actually, it displayed well. There was output, otherwise the bot would have shown debug info instead.

@Adám that's why I blamed chat ;-p

@EriktheOutgolfer So while my last function solves the problem of sorting text, it does not provide Total Array Ordering, as it would consider `A` and `66` the same. And two different arrays should sort identically. I have a solution in mind which solves this for almost any array.

12:34 PM
⎕←+/ (⍳11-1)*2

```@RosLuP
385```

⎕←1+4+9+16+25+36+49+64+81+100

```@RosLuP
385```

1:11 PM
duh, it's annoying how GNU APL doesn't have a GUI

@EriktheOutgolfer What is it in GNU APL that you desire?

@Adám how much I can criticize it :p
honestly though, you need 1) a special terminal profile 2) applying very strictly enforced syntax rules 3) some nonsensical parsing in the case of hybrids 4) to invoke it with a special command that will make it support ``` key combos 5) etc. ...∞) to work within a goddamn terminal

@EriktheOutgolfer 6) messed up dfns 7) limited ⎕RE (subset of ⎕R and ⎕S) 8) `⎕DLX` (Knuth's algorithm X) which is much slower than a short Dyalog dfn.
@EriktheOutgolfer `⎕DLX` to solve a hard Sudoku puzzle in GNU APL took 60 seconds while the dfns Sudoku solver took 24 milliseconds in Dyalog APL.

@Adám ∞+1) it doesn't really feel like APL
btw @Adám can a dfn have an argument in `[]`, i.e. `left{...}[extra]right`?

1:27 PM
@EriktheOutgolfer No, not in Dyalog APL, as that breaks normal APL syntax. However, a dop can be `left(extra{...})right` or `left({...}extra)right` which does follow APL syntax.

@Adám oh so only some builtins can do that or tradfns can too?

@EriktheOutgolfer All operators can do that. Dyalog APL is consistent.

oh so tradfns can't do it either...wait huh
oh so only operators can use `[]`

@EriktheOutgolfer No, only old APL "stuff" (primitive fns/ops) can do that. E.g. `/[x]` and `⊂[x]`. But really it shouldn't be used now that we have `⍤`.

@Adám cries over ruined golfing opportunity

1:34 PM
@EriktheOutgolfer What do you mean?

@Adám is `⍤` in the codepage?

@EriktheOutgolfer I fixed that issue.

⎕←'⍤'∊⎕AV

```@EriktheOutgolfer
0```

@EriktheOutgolfer If your code uses one or more of `⍤⌸⍠⊆⍸⌺` just add a star to your header: `APL (Dyalog Unicode), 123 bytes*` and then at the bottom write `<sup>* using SBCS</sup>`.
@EriktheOutgolfer … where "SBCS" refers to my "precompiler".

1:38 PM

11

Yes, it is valid Consider C. In order to run a C program, it is first passed through a compiler (like gcc or clang), then a linker (like ld or gold), and then the resulting executable is run. We have no problem with this (but we require the compiler to be specified, since different compilers imp...

@Adám there's one answer of mine that I think can benefit much from that :p (quantum drunkard, taking advantage of no "non-competing" anymore)
dunno if I'll beat ngn's though

@Adám just an FYI, I think there's a typo in your SBCS page in the very first line `Use this these functions to enable storing...`

@J.Sallé thanks, fixed.

2:26 PM
I wonder if people have been doing the advent of code in APL. I should give it a try

I've been mostly doing it in jelly :p

@Adám `c\$65 or "c"\$65 depending on version

@EriktheOutgolfer That could work too. I'm stuck on day 3 with not a single idea as to how to approach the issue...

@Ven for me the idea is there, the speed isn't there

@EriktheOutgolfer I'm interested in suggestions
unless it's "just generate it and then walk it" :P.

2:40 PM
@Ven sorry, I can't spoil it to you :p I'll be spoiling a very large part of the challenge

oh, you won't be spoiling anything, I gave up on this one.
I found a math.SE post that has very complex formulae and threw the towel.

btw I haven't got to the second part yet
the input is very large

lol, so you are generating it?

there has to be a better way ._.
well, I'm sorry for the offtopic

2:50 PM
@Ven Why do you think it is off-topic?

I'm not strictly talking APL :).
I do have a slight idea as to how I'd do generation like that in APL, but I'm not good enough to do it in a non-imperative manner

@Ven K and J are on-topic here.

@Adám and of course APL is also on-topic, and Ven wanted to do it in APL as well

well I'm thinking of doing it in APL, I just don't have the mind for that

3:06 PM
@EriktheOutgolfer Sorted!

@Adám ...woah that's a giant mess, will probably take 6-8 weeks to understand

@EriktheOutgolfer I was gonna say something similar
I don't think it's a mess, just kinda confusing at first sight

@EriktheOutgolfer @J.Sallé You do realise that most of the code is imported from dfns right?

@Adám I did not, actually, I just assumed you imported the dfns for `lex`
not even sure if that's a Dfn though
I also didn't get why `⍎'''le''⎕CY''dfns''⋄⍬'` need to be executing these strings instead of just typing them

@J.Sallé `⎕FX` suggests that `lex` isn't imported, but `le` is imported

3:14 PM
@EriktheOutgolfer yeah I think it's actually called `'le` (with an apostrophe)

@J.Sallé no way
you can't call anything that, it's not Haskell :p

having to read left-to-right and right-to-left at the same time is a bit complex

it's `⍎` that takes the code as a string

@EriktheOutgolfer that's also invalid in Haskell, fwiw :P.

@EriktheOutgolfer `⍎'''le'` executes the string `'le` though

3:15 PM
@J.Sallé `'''le''⎕CY''dfns''⋄⍬'` is one string

oh duh
I thought there was a space there

spaced out, it's `' '' l e '' ⎕ C Y '' d f n s '' ⋄ ⍬ '`

Yeah, I got it now. I thought there was a space between `le'` and `'⎕CY`
Which brings me back the my question: why the heck is `⍎'''le''⎕CY''dfns''⋄⍬'` being executed instead of just typed?

@EriktheOutgolfer @Ven @J.Sallé Ungolfed.

Also, I like the way `zip←{↑⍉↓⍵}` looks.

3:30 PM
@J.Sallé Yes, but TIO doesn't have url shortening, so the link couldn't fit while also showing that it works. However hastbin's syntax colouring for APL is bad (I think it thinks it is a Visual Basic Script. Gist works better.

@Adám I see. Could you clarify why you used `⍎'''le''⎕CY''dfns''⋄⍬'` instead of just typing `'le' ⎕CY 'dfns'⋄⍬` ?

@J.Sallé Because `⎕CY` does not return a result (we should fix this) but result-less expressions are not allowed in scripts, so by encasing it in execute, I could take advantage of the fact that the result of execute is the last statement, i.e. `⍬`.

@Adám sorry, what's that snippet doing?

@Ven Implements sorting and grading of any APL array whatsoever. Maybe I shouldn't have pinged you as you were just commenting in passing on something that EtO and JS were discussing.

@Adám Ooooooh, it's basically a workaround then. Nice, good to know.

3:39 PM
@J.Sallé That's what the bot does too so it can enable boxed display.

@Ven It is a follow-up to yesterday's lesson.

Ah, I failed to follow that, it happened just as I was decommuting. I'll catch up to them at some point :).

Yeah I also need to read through the last lesson, I wasn't here unfortunately

@Adám everytime I start doing a bit of APL I end up reading a bit on the dfns & idioms and it's always a bit overwhelming.

3:52 PM
@Ven I'll be happy to help if I can. The dfns workspace and the idiom list are intended as compact tools, not necessarily the best place for beginners. Reviewing the lessons may be a better fit. Also, all (I hope — let me know if you find one that isn't!) my code golf submissions are fully explained, usually function-by-function.

it's always a bit overwhelming, having to switch my "brain mode" :-).

4:36 PM
See, I think I know what most of the operators do in their basic versions. That means no idioms and all.
But reading and understanding `~≡/⍴∘⍴¨⍵:∇ xrnk ⍵ ` is kind of a challenge...
now, it's doable, and it takes me but a few minutes. Getting to a level where I'd be able to write that, however...
Oh! We're live!

5:08 PM
in The Nineteenth Byte, 6 mins ago, by Pavel
@APL_Wizards If I have a list of numbers `l`, how might I map them like so: `f[1], 2×f[2], f[3], 2×f[4], f[4], 2×f[6], ...`

alternative 1 and 2 multiplier?
With explicit arguments, something like `{⍵×(⍴⍵)⍴(1 2)}`

⎕←⍴(1 2)

```@Pavel
2```

⎕←(2 4 6 8 10)⍴(1 2)

```@Pavel
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2

1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2

1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2
1 2 1 2 1 2 1 2 1 2

1 2 1 2 1 2 1 2 1 2```

5:14 PM
Um. I think I'm not understanding how ⍴ works

the left argument is the shape. (`dim1 dim2 dim3`...)

Ah

so, I use `⍴⍵` (monadic rho, shape of ⍵) to replicate the correct shape.

Ah, I see.

dyadic `⍴` rho will loop on its right values if it ran out.

5:15 PM
That makes sense now
What if I wanted to multiply a list by, say, `1 4 2 4 ... 2 4 1`?

What's the pattern there?

`4 2`, but starts and ends with `1`
`1 4 2 4 2 4 2 4 2 4 2 1`

`{⍵×(1,1,⍨(¯2+⍴⍵)⍴(1 2)}2 4 6` or something?
assuming the length is always at least 2 and you only have only a single dimension

Yeah

I manually add the `1` with `1,`
Tryapl is down, so my APL capabilities are down with it tho..

5:20 PM
You can use the APL bot here, or tio.run/#apl-dyalog
⎕←'foo

```@Pavel
line(1,79) : error AC0607: unbalanced quotes detected "(⎕NS⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''box on -fns=on -trains=tree''⊣enableSALT'⋄⎕←'foo"
^
Complete: 1 error.
DOMAIN ERROR: There were errors processing the script
'#'⎕NS ⎕FIX'file:///home/runner/.bin.tio.dyalog'
∧

Real time: 0.060 s
User time: 0.006 s
Sys. time: 0.023 s
CPU share: 49.02 %
Exit code: 0```

Welp
Not quite what I meant to show off there

yeah, that I know, but it's very spammy.

It's not a REPL, however :).
my top-down APL abilities are very limited :P.

5:24 PM
I'm the other way around. I don't really like how APL essentially forces you into a REPL.

A pointless version of my former thingie: `(⊢×(⍴∘1 2)∘⍴)2 4 6`

What the |- symbol on the left there?

`⊢` is the right tack. It just returns its argument.
⎕←(⊢×(⍴∘1 2)∘⍴)

```@Ven
┌─┼─┐
⊢ × ∘
┌┴┐
∘ ⍴
┌┴┐
⍴ 1·2```

5:39 PM
Ah, seems like tryapl's primer does not like `:` and `::`.

2 hours later…
7:38 PM
what's the APLy way to get the element of the array for which the 1st element is something specific? e.g. `('abc' 1 2 3) ('def' 4 5 6) ('ghi' 789)` and `'def'` give `('def' 4 5 6)`

1 hour later…
8:41 PM
@Ven It's fine, you can use it. Others may learn from what you do (even mistakes).
@dzaima You're looking for the one where the first element (i.e scalar) is `⊂'def'` not `'def'` so:
⎕←(⊂'def'){⍵⊃⍨⍺⍳⍨⊃¨⍵}('abc' 1 2 3) ('def' 4 5 6) ('ghi' 789)

```@Adám
┌───┬─┬─┬─┐
│def│4│5│6│
└───┴─┴─┴─┘```

@Ven Or just `⊢×1 2⍴⍨⍴`

@Adám I was getting there when you posted this :p the freaking `⍨` gets me every time though

@J.Sallé ⍨

It's my favourite looking squiggle though

8:52 PM
@Adám why though? is the first element of `('def' 4 5 6)` not `'def'`?

@Ven No need to over-parenthesise, as APL functions are strictly right-associative: `{⍵×1,1,⍨(¯2+⍴⍵)⍴1 2}` or `{⍵×1,1,⍨1 2⍴⍨¯2+⍴⍵}` or golf it one byte to `{⍵×1,1,⍨1 2⍴⍨⍴2↓⍵}` or go tacit with `⊢×1,1,⍨1 2⍴⍨⍴2∘↓`
@dzaima Depends how you look at it:
⎕←1⌷('def' 4 5 6) ⋄ ⎕←1⊃('def' 4 5 6)

```@Adám
┌───┐
│def│
└───┘
def```

@dzaima When you say "element", isn't an element one thing, i.e. a scalar? It happens to be that that scalar contains a three-element vector, but so what?
@dzaima Another way to look at it is that `⍳` looks up all the elements of its right argument, but you don't want to look for `'d'` and `'e'` and `'f'`, but rather the thing as a whole, i.e. `⊂'def'`.

oh so whenever a string is in an array it's automatically wrapped in a scalar
I think I understand why, but `⊃ 1⌷ ⊃ 1⌷ ⊃ 1⌷ (((('hi')3)2)1)` feels like too many unwrappings (though the `1⌷`s are removable there? do some functions just automatically unwrap out of the scalar?)
why do I keep getting `The current stack trace is 17 levels deep. Do you want to open all the trace windows?` on errors?

9:19 PM
because there's a possibility you don't want to be filled with trace windows one behind the other :p

@EriktheOutgolfer I don't want any trace windows at all whatsoever :p

see? that's kindness!

@EriktheOutgolfer and I don't want a message about it too because I get errors way too often to click 'no' every time
I have no idea what I did to make that happen and no idea how I got rid of it.

unfortunately the interpreter can't know when you do want them and when you don't

@EriktheOutgolfer well it knew and then it didn't and then it did again

9:38 PM
oh, by some reason when my dfn errors the REPL stays inside it (as now doing `∇` returns the function)

@dzaima You cannot trace into a one-liner dfn or a train, so if you only have such ones calling each other, you will not be offered trace windows.
@dzaima Well, you can do it like that, but `1 1 1⊃(((('hi')3)2)1)` is simpler.

@Adám but that that's a possibility is what confused me. I think I got the hang of it though

@dzaima The tracer is actually very useful. You can inspect names and experiment in the session with names that are local at this stack level, and then you can change the tracer into an editor, and fix your code, escape that, and then either resume execution or step through lines. In APL, you are allowed to modify functions even when they are on the stack or indeed half-way executed.
@Pavel How so? you can use scripts written in an external editor and just use APL as an evaluation machine.

@Adám Evaluating scripts with `dyalog` is just really akward compared to most languages.

@Adám oh so that's what's happening. How would I exit that without action->reset?

9:46 PM
@dzaima Press Escape until back out or just enter `→` in the session.
@Pavel Yeah, we are working on that.

@Adám to pick every `xth` element of a vector, should I do `x⊃/vec`?

@Adám I know, and I can't wait.

Nope, that doesn't work

@EriktheOutgolfer @dzaima Not true. Just tell the interpreter `⎕TRAP←0 'E' '⎕DMX'` (trap all errors and give me the diagnostic message extended)
@J.Sallé Define "every xth"? You mean like xth, 2xth, 3xth?

@Adám every 2nd element, for example

9:53 PM
@J.Sallé Like this?
⍞←2{⍵/⍨(⍴⍵)⍴⍺↑1}'Hello World'

`@Adám HloWrd`

`@Adám HloWr`