« first day (1776 days earlier)      last day (44 days later) » 

4:39 AM
myf1 ← {

any idea why multiple line function in RIDE does not work?
i always got error when I input a statement at the middle { and }
0 = ⍵ : 0 ⋄ 1 how to put the expression between { and }
myf1 ← {0 = ⍵ : 0 ⋄ 1}
how do I do multiple line in above funcion? open and close bracket in different line
my ← { cursor } , then I press CTRL-o, split the bracket in different line, but when I type expression: 0 = ⍵ : 0 ⋄ 1 and press ENTER, I got error
I'm on MacOS
5:20 AM
You can use ]dinput, or type in the name and double-click it to open an editor for the function and write the function body there
or )ed myf1 if you hate clicking
or start by writing ∇f←{
and write the rest of the body and close the edit mode with in its own line
Proper multiline dfn support was planned I think but I don't recall the timeline
5:33 AM
myf2 3
VALUE ERROR: Undefined name: myf2
      myf2 3
@Bubbler, I got undefined error,
myf2 ← {
     0 = ⍵ : 0 ⋄ 1
here is my code in other window,
and I try to call the myfun2, i got undefined error,
Oh, you have to save the function in the other window (the circle-X button is save+close)
@Bubbler, thx, it works
You can save and keep it open but it requires setting a shortcut for "FX" (Edit - Preferences - Shortcuts)
Oh.. I seems to me RIDE need more works to make it more productive..
you cant even change fonts
5:38 AM
But it is better than nothing.. at least I can write multiple line function,
 r←proc2(i d);tmp;⎕IO
 {a b←⍵⋄r[a]←b}¨↓{⍺,⍴⍵}⌸d
today's a little bit tricky, part 1 is too straight forward for APL that I spent lots of time for part2. I guess many would solve the part2 already when doing part 1.
Btw my answer is bigger than 2*41 so it's a good idea to set ⎕PP←20, for any new comers to APL.
Btw2: although the results overflows to floating point numbers (Dyalog has only 32bit integer), there's still enough precision so no need to worry about accuracy.
6:31 AM
Right, float64 can perfectly handle integers under 2^53, which is enough for AoC purposes
i see a goto
2 hours later…
9:46 AM
I think @xpqz has established an online APL book: xpqz.github.io/learnapl/intro.html
in The Nineteenth Byte, 59 mins ago, by PyGamer0
^ any way to do suffixes tacitly?
@PyGamer0 ⌽¨prefixes⍤⌽
well that was simple
Or just ⌽¨,/⍤⌽ of course.
10:09 AM
what does ⍣¯1 do?
when applied to a function
f⍣¯1 applies f "in reverse", i.e. R←(f⍣¯1)X gives a result such that f R gives X.
E.g. 2∘×⍣¯1 divides by 2.
And 'a'∘,⍣¯1 removes a leading 'a' (and errors if there isn't one to remove).
@PyGamer0 Btw, did you try asking APLcart?
how many entries does APLCart have?
oh wait
Look at the bottom!
10:15 AM
yeah it was covered by chrome
@PyGamer0 Really? Could you screenshot that? Maybe I can fix it.
compared to BQN crate, about a 1000 more
well i have to scroll in android
Ah, then the browser doesn't correctly communicate the hight to the CSS.
Maybe there's a better way to code it. I should revisit it. My understanding is that things go bad on iPhones too.
10:58 AM
@xpqz I was doing day 2 during the weekend but find my code clumsy dealing with conditional logic for the 'up' 'down' 'forward'
@jimfan You can see what I did here, if you like - gist.github.com/xpqz/d406eb493fd2a875ae463cce009463af
11:10 AM
@jimfan I separated out the ups, downs and forwards with a match inner product, but there are other ways.
2 hours later…
12:41 PM
@xpqz I had a quick glance at yours to get a hint, but I'm pretty happy with my encoding of the "next state" function: github.com/rikedyp/Advent-of-Code/blob/main/Y2021/Day6_2.aplf
2 hours later…
3:05 PM
And this is what I have:

S←'forward 5 down 5 forward 8 up 3 down 8 forward 2'

M←((2÷⍨≢V) 2) ⍴V←(' '≠S)⊂S

×/ ∊ +/ (∊1↑¨,1↑[2]M) {⍺='f':(⍵ 0) ⋄ ⍺='u':(0 ¯1×⍵) ⋄ ⍺='d':0 ⍵}¨ ∊⍎¨1↓[2]M
Can you explain in words what you are trying to do?
⎕←M←((2÷⍨≢V) 2) ⍴V←(' '≠S)⊂S←'forward 5 down 5 forward 8 up 3 down 8 forward 2'
      ⎕←M←((2÷⍨≢V)2)⍴V←(' '≠S)⊂S←'forward 5 down 5 forward 8 up 3 down 8 forward 2'
That expression of yours errors.
It must be I was using NARS2000 instead, seems like the tally function does not exist in Dyalog
@jimfan It sure does.
3:13 PM
Tally returns a scalar for number of element in the array
But should be in Dyalog (unless you set ⎕ML←3)
By M←((2÷⍨≢V) 2) ⍴V←(' '≠S)⊂S I am trying to tokenise and transform the resultant array into a two column matrix. First column is the commands such as 'forward' 'up' 'down'. Second column contains argument of the commands.
⎕←M←((2÷⍨≢V)2)⍴V←(' '≠S)⊆S←'forward 5 down 5 forward 8 up 3 down 8 forward 2'
│down   │5│
│up     │3│
│down   │8│
Yes @Adam, just like that
And by (∊1↑¨,1↑[2]M) {⍺='f':(⍵ 0) ⋄ ⍺='u':(0 ¯1×⍵) ⋄ ⍺='d':0 ⍵}¨ ∊⍎¨1↓[2]M I am trying to convert each row of the matrix in an array e.g. 'forward' 5 gives (5, 0), 'down' 5 gives (0, -5)...etc
3:17 PM
@jimfan You should put backtick around inline code to make sure markdown misinterpreting certain things.
Let me try:

`(∊1↑¨,1↑[2]M) {⍺='f':(⍵ 0) ⋄ ⍺='u':(0 ¯1×⍵) ⋄ ⍺='d':0 ⍵}¨ ∊⍎¨1↓[2]M`
Heh, it doesn't work in multi-line messages.
Again (∊1↑¨,1↑[2]M) {⍺='f':(⍵ 0) ⋄ ⍺='u':(0 ¯1×⍵) ⋄ ⍺='d':0 ⍵}¨ ∊⍎¨1↓[2]M
Maybe read through apl.wiki/APL_Orchard#Features
No problem
3:19 PM
Btw, : does not require parenthesis around the result expression on its right. Indeed, that parenthesis can cause strange behaviour.
Thanks, just tried and found the parentheses are redundant
Not just redundant:
What does the underscore stand for?
Nothing. It is just a normal name, but often used as a "sink".
3:54 PM
@Adám is it like the underscore in python, an anonymous variable?
@milia it's a completely regular variable name
@milia are you available now?
1 hour later…
5:19 PM
Very similar to @rak1507, but without the crazy train. :) (Love the use of depth for the constant 1!)
@klao yeah, originally had ⌽⍨∘1 but realised I could golf off a character
@klao Do you mind me adding this to apl.wiki/Advent_of_Code?
@Adám No, not at all! I'm quite proud of it, to be honest :)
Question: how do you "box" the major cells of a higher rank array? I couldn't find it on APL cart
@klao ⊂⍤¯1
@klao Nice. I'll add that.
5:25 PM
@RikedyP hey, sorry, just saw this, I wasn't on the laptop. Let me know if and when you're available. Feel free to ping me on discord :D
{⊂⍤¯1⊢1/⍵}Y is on aplcart, which is similar
Oh, right, meaning I need to add keywords on that instead?
@rak1507 Thanks! I really need to understand the rank operator. Tried it, but not with -1
imo you can just replace it with ⊂⍤¯1 without 1/⍵
Then it doesn't always give a vector.
5:27 PM
sure, but only for a scalar, and who cares about that
(and if someone needs it to work for a scalar, it's easy to modify yourself)
the key part is ⊂⍤¯1 which is what someone cares about
I care, but isn't ,⊂⍤¯1 the same as {⊂⍤¯1⊢1/⍵}?
@Adám if it is I'd replace it with that instead probably
Pushed. Thanks, both!
2 hours later…
7:21 PM
In the Windows IDE, anyone know if there are shortcut keys for opening and closing :section/:EndSection constructs?
@PaulMansour In the main editor pane or in the tree view?
In the main editor pane. I'm not even seeing section in the tree view - I thought I should see them...
Then I'm fairly sure there's no such shortcut. Do you want to email support@ about it, or should I log an issue for you?
Thanks... I'll email support, but I'll play around a bit first. I see that sections show up in the tree when editing a class, but not when editing a function, plus a few other oddities when editing functions with sections.
I'll gather up all the issues...
Here's one more: :Section outside a function doesn't indent its content.
7:56 PM
My little mind was blown again while working on day 5 of AoC. I was working on generating intermediate points between the start and end of horizontal and vertical coordinate and was noodling with an inclusive range `⊣↓∘⍳1+⊢`.

Accidentally applied it to the coordinate pairs directly and it generate all the pairs between them! Coolest thing I've seen thus far. It makes my implementation dog slow, but I thought it was too neat to refactor.
2 hours later…
9:40 PM
 S ← {(⍵ ⍵⍵ ⍺) ⍺⍺ (⍺ ⍵⍵ ⍵)}
      cmp ← -S≤
what does ⍵⍵ mean?
or what does ⍺⍺ mean?
You've defined a dyadic operator. ⍺⍺ and ⍵⍵ are the operands.
Did you try APLcart?
10:27 PM
hi, new here. How do I get the index of a table in J? I can see from the documentation that I. applies row-wise, but how do I get something akin to iota-underbar in APL?
a boolean table, I should add
@ElectricCoffee Welcome. You want the indices of all the true elements in a matrix?
well just the ones that are 1
You can ravel, do I. and then represent in the shape radix.
   ]t=.?3 3$2
0 0 1
0 1 0
1 0 1

0 2
1 1
2 0
2 2
$#:I.&, tacitly.
sorry, I was typing up a quick apl example
⍸1-⍨?10 10⍴2
the indices of a random 10x10 boolean matrix
Sure, that's what I did above, although the result you'll get is a flat matrix.
If you want a vector of vectors, just apply <"1 to the result.
10:32 PM
I don't think that's too much of a concern at this stage, but I'll keep that in mind, thanks
Aw shoot. Running into WS FULL when I try to run my function enough times to satisfy day 6 of AoC. https://git.sr.ht/~adregan/advent-of-code-2021/commit/ae52abf8a0d7d01f55766184ca095d5f64fe4e5f#6.apl

Any ideas on a fruitful direction to go in at this point?
@adr need to make it more efficient
it uses exponential space
@adr Increase MAXWS.
@Adám that will not work
the current implementation is not space efficient enough
64-bit memory addresses won't cut it? ;-)
10:40 PM
lol, well, if you have 2TB of ram, it would work
Doable, but expensive.
yeah, easier to optimise it I think :P
lol. I considered increasing maxws but figured that's not a sustainable solution long term :) (also have no idea how to do it). My solutions are really slowing down.

Any good resources on efficient APL techniques?
@adr well here it's not really APL specific, think about what you need to store + how you could simplify the representation
Maybe some sort of sparse representation could work?
10:52 PM
... how do I commute in J? NuVoc doesn't mention commute, flip, or swap, and I can't seem to find it
idk why it calls it 'reflex', but it does (nuvoc never has good names...)
because it applies reflexively
You actually need "passive" "voice".
commute was always a weird name to me, because commutativity just means that a ? b is the same as b ? a, where ? is some operator
I think someone tried coming up with a name that'd fit both the monadic and the dyadic use.
(Heh, we need a Jbox to complement APLcart and BQNcrate.)
10:57 PM
And Kargo for K :)
wait, why is it called "passive"?
"down the tree" → "the tree is downed"
A passive voice construction is a grammatical voice construction that is found in many languages. In a clause with passive voice, the grammatical subject expresses the theme or patient of the main verb – that is, the person or thing that undergoes the action or has its state changed. This contrasts with active voice, in which the subject has the agent role. For example, in the passive sentence "The tree was pulled down", the subject (the tree) denotes the patient rather than the agent of the action. In contrast, the sentences "Someone pulled down the tree" and "The tree is down" are active sentences...
Because it swaps subject and object for a verb
I forget that J likes to use grammatical terms moreso than mathematical ones
still, to me "passive" sounds like "lazy", as in lazily evaluated, which is why it never crossed my mind to use it when I scanned through nuvoc
11:01 PM
Are there any other operators that change their functionality when given an array operand. I can only think of selfie, ⍨
there's also inverse
Ah, better example: "Bob drove the car" → "the car was driven by Bob"
@FawnLocke f⍤x rank, f⍤g atop
11:02 PM
True, true
I need something like NuVoc for APL. I find the Dyalog docs harder to navigate
I'm glad APLWiki is even a thing, or I'd never have found I.
You know about APLcart.info?
There's the refcard
The parent directory for that link is also quite useful. docs.dyalog.com/18.0
11:04 PM
sometimes you just need a simple grid with the symbols and their uses
but I digress
I agree
the reference card is a bit overwhelming at first glance, and aplcart is more geared towards idioms than an index to wiki pages about the various symbols and their uses
That does exist but it's slightly ugly and hidden away
@FawnLocke ?
11:06 PM
Gimme a second
There's a grid of symbol ("language elements") but doesn't have the names/meanings.
there's a side-project if I ever knew one
Ah, yep. That's what it was.
Ol' (old) as opposed to Nu' (new) ;P
@ElectricCoffee Uh, it exists.
11:08 PM
(I frankly find the old voc easier to look at than NuVoc, but sadly, the old one isn't maintained.)
and here I thought I could be cute with the naming
having old be APL because of its relative age
There are these tables.
But APL doesn't have a 2D symbol system like J does.
it arguably sorta does? if you think of it in the old typewriter sense with combined characters
Language Elements but with function names next to each symbol (e.g. + Conjugate | Plus) would be awesome indeed. Currently the doc page for each arity or functionality is two clicks away instead of one
11:12 PM
they're just treated as separate glyphs in unicode
but yeah it's not really a system in the same way it is in J
@Bubbler aplcart.info?q=primitive gives you almost that, only as a single column.
@ElectricCoffee And they are barely related, e.g. ~ vs vs ¨ and vs vs
In fact, even is an overstrike of < and > or and
⎕←⎕FMT'<',(⎕UCS 8),'>∧',(⎕UCS 8),'∨'
@Adám ⋄⋄
anyway I gotta go, nice meeting everyone
@Bubbler Should be trivial to generate based on say the JS language bar.
11:21 PM
Also, "Defined Fns & Ops" in Language Elements links to an orphaned page
@Bubbler Yeah, because it is all really one long book, so you'd continue on the next page.
@rak1507 Oh duh I can just keep counters on an array. Glad to rubber duck it a bit with y'all. I was just so excited to be done quickly I was blinded hoping for a quick fix.
@Adám I mean, it is a page that doesn't appear in the Contents at all, so there's no next page
and "Variables" links to "Arrays" which doesn't look right
@Bubbler All vars are arrays ;-)
Then f in f←+ is not a variable?
11:28 PM
Then what is it called?
A name.
@Adám can i learn more about APL?
Sure. Can I be of help with anything in particular?
11:39 PM
ok, 2 questions: if statements to check equality, input
a≡b returns 1 if a and b are identical, 0 otherwise.
if statements?
Well, in a traditional function, you can use :If condition:EndIf
But in APL, we generally try to avoid that.
@Adám why?
Because it leads to better and faster code.
11:42 PM
@Adám but why?
so we use but why not?
It allows you to think about the problems at a higher level, and allows the computer to used vector instructions.
@Adám i don't understand.
E.g. to get all the elements of a that are greater than 3, you could loop over the array a and conditionally append each element to the result list…
But the APL way is to compare all elements in one go, giving you a Boolean list, then use that to filter the original list.
E.g. if the list a←3 1 4 1 5
Then a>3 gives 0 0 1 0 1
And then 0 0 1 0 1/a gives 4 5
i still don't
what about input?
@Fmbalbuena It takes the computer about the same time to compare two numbers as it does to compare a bunch of numbers, and you dont' have to worry about any for loops or counters or result variables.
@Fmbalbuena returns one line of text from stdin.
11:47 PM
@Adám syntax (f = input[EmptyString])
Not sure what you mean by that.
let f be the first line of input
f←⍞ exactly does that
What does "[EmptyString]" do?
@Adám nothing
11:48 PM
So why include it in your pseudo code?
Input[EmptyString] means read a line of stdin without output
Oh, like "prompt"?
or Python's input() I guess
@Bubbler yeah
Like input('Enter a number: ')
11:50 PM
Well, you might want to keep in mind that I don't know Python when you ask me things…
Anyway, yes f←⍞ is what you want.
@Adám lower input?
(lowercase the input)
Do you know about APLcart?
yeah but syntax?
Exactly as shown: ¯1∘⎕C
but where i do put the variable?
11:54 PM
@Fmbalbuena Y is the variable, so simply replace Y with the thing you want lowercased. in this case.
@Bubbler like this?

« first day (1776 days earlier)      last day (44 days later) »