« first day (1784 days earlier)      last day (1167 days later) » 

00:01
@Adám why?
@Bubbler When you absolutely need an impure function and the argument just isn’t necessary? Is it idiomatic to pass in an empty list and ignore it inside the function?
@Fmbalbuena Technical limitations in how we've implemented it.
@Adám wdym?
@user Yeah, either that, or use a tradfn.
how do you implement?
@Adám ^
00:03
@Fmbalbuena TryAPL executes expressions and captures the results, feeding them back to the frontend. Inline printing would need to be paired up with what caused it, which is non-trivial because all the incoming request are run in parallel in the same single interpreter.
That said, I think I just came up with a way to do it…
@Adám Would a tradfn be considered more idiomatic in that case?
@user I think that's a matter of taste. Some swear by dfns. I'd use a tradfn.
Good to know
I'd use a dfn that ignores its argument if I need to be able to apply it multiple times.
E.g. {⍞←'.'⊣⎕DL÷5}¨⍳10
@Adám is there a way to interpret that is valid in TryAPL?
00:08
No. And it makes no sense on TIO either. You need an installed interactive session (REPL) for it.
@Fmbalbuena You're missing the argument name
Are you asking why you need the ?
@Adám oh sorry
{} is lambda
00:11
Yes.
empty list?
Empty of what?
Empty list like [] in python.
In APL, there's a difference between and empty bag of potatoes and an empty shopping list.
@Adám ???
00:13
Remember dyadic ?
@Adám Yes
What do you think 0⍴0 will give?
@Adám the output was:
Just describe it in words.
⋄0⍴0
00:14
@Fmbalbuena Response looks like a 1-by-0 matrix.
Sure, but what is it.
What should it be?
empty list
and why 1, returns [1]?
Correct.
@Fmbalbuena It doesn't.
What do you think 0⍴'a' should give?
(in words)
@Adám gives: (in words)
Please describe the result in your own words.
00:17
ok gives empty string
Good.
Now, what do you think 3⍴0⍴0 should give?
@Adám still empty string or [0, 0, 0] maybe.
It does indeed give 0 0 0
What do you think 3⍴0⍴'a' should give?
empty string
The left argument to dictates the result shape, so the result must have 3 elements.
00:19
⋄3⍴0⍴'a'
@Fmbalbuena Response looks like a 1-by-3 matrix of whitespace characters.
Yeah, it gives ' '
now i have to gtg. now.
 
5 hours later…
05:02
⋄ ⎕←z←3⍴0⍴0 ⋄ ⎕←y←3⍴⍬ ⋄ y=z
@PyGamer0
0 0 0
0 0 0
1 1 1
 
4 hours later…
08:54
@PyGamer0 is short for (0⍴0)
@Adám i have seen xpqz's blog about that
@Adám lambda not working
@Fmbalbuena Unpaired )
⋄⎕←'cba'{⍵,(,⍨⍺)}'abc'
@Fmbalbuena abccbacba
09:09
OK then
what's the trick to today's aoc part 2? I tried maintaining a count of the letters but my technique is too slow
:59873434 Please do not remove your mistakes, as that makes the transcript hard to understand for others. If you need to experiment, you can do so on TryAPL or in the Sandbox.
@Adám I need to convert number to unicode
@Fmbalbuena But not like ⎕UCS?
I forgot thanks.
@Fmbalbuena Are you aware of APLcart?
09:18
@Adám ⎕←'Hello, World'{⍵,⎕UC⍺}32+1
@Fmbalbuena
NOT PERMITTED: Illegal token
      ⎕←'Hello, World'{⍵,⎕UC ⍺}32+1
     ^
@Fmbalbuena S
⎕←'Hello, World'{⍵,⎕UCS⍺}32+1
@Fmbalbuena 33 72 101 108 108 111 44 32 87 111 114 108 100
you realize you can edit your previous message within 2 minutes of posting it?
09:20
@Adám ⎕UCS Can convert string to list of numbers?
@PyGamer0 yep but i'm not editing
Yes.
@Fmbalbuena Editing is fine. Removing is problematic, as it makes the transcript hard to understand.
yeah
⎕←'Hello, World'{⍺,⎕UCS⍵}1+1×64-32+1*2⋄⍞←'Random error'⋄⎕←1=2≠3≤4>5≡6≢7 ⍝ Comment
@Fmbalbuena
Hello, World
NOT PERMITTED: Illegal token
      ⎕←'Hello, World'{⍺,⎕UCS ⍵}1+1×64-32+1*2 ⋄ ⍞←'Random error' ⋄ ⎕←1=2≠3≤4>5≡6≢7
                                               ^
@TryAPL why?
09:26
⎕←'Hello, World'{⍺,⎕UCS⍵}1+1×64-32+1*2⋄⎕←'Random output'⋄⎕←1=2≠3≤4>5≡6≢7 ⍝ Comment
@Fmbalbuena
Hello, World
Random output
1
1=2≠3≤4>5≡6≢7
1=2≠3≤4>5≡1
1=2≠3≤4>0
1=2≠3≤1
1=2≠0
1=1
1
@Adám ^ Correct?
yes
@Adám Can you teach one more command?
Sure. Time to learn
It is a monadic operator, just like
09:29
what it does?
It takes a dyadic function on the left, and "inserts" it between the elements of the (single) argument:
⋄ 3+4+5 ⋄ +/3 4 5
@Adám
12
12
We call it "Reduce" because it reduces the "Rank" (number of dimensions) in the argument (if possible).
⋄ 3*4*5 ⋄ */3 4 5 Right to left?
@Fmbalbuena
DOMAIN ERROR
      3*4*5 ⋄ */3 4 5
       ∧
09:31
why
Because * is power, not multiplication, and 3*4*5 is about 3.7×10⁴⁸⁸ which cannot be represented as a 64-bit floating point number.
@Fmbalbuena Yes, every APL function takes as right argument, everything to its right.
@Fmbalbuena Can you write a factorial function based on just what I've taught you? E.g. Fac 3 should give 6 and Fac 5 should give 120.
10:11
anyone do aoc today? pretty fun
@rak1507 got it just now
I was drudging through brutish methods until the key the solution showed itself
do you have a link?
@rak1507 yeah one moment
haven't cleaned it up
@RikedyP TIL ''⎕NS
10:17
@Adám I'm still experimenting with how to make my ##.kit dependencies nice. ⎕PATH won't cut it if it fails on dervs and idioms
this is like an import statement I guess
there's a nice (imo) matmul based method github.com/rak1507/Advent-Of-Code-APL/blob/main/2021/…
@RikedyP Wait, so does ''ns.⎕NS copy to ns?
@Adám ¯\⍨/¯
@rak1507 That is nice, seems like something @RGS would figure out - mathsy people
@rak1507 yeah my part 1 was just implementing the description - I suspected it would fail for part 2 but was too stupid to figure it out all at once
10:20
@RikedyP It does, but of course that makes the right argument relative to ns, so a bit less useful.
yeah, I did the same (but my part 2 ended up shorter than part 1!)
@rak1507 Yeah once I figured out a couple of optimisations mine got shorter - I'm sure I could clean up my part 2 and make it more functional - maybe I'll do that and then do a runtime test between matmul and key
@Adám right, I'm also not that happy about my ref hack '#.kit.'∘,¨
but maybe it'll have to do
@RikedyP Which namespace does the code live in? I.e. what is ⎕THIS?
I mean a function or namespace having its own import statements isn't a bad thing, but we're just bumping up against the slightly ugly way Dyalog handles system shizz
@Adám #.Y2021 sibling of #.kit
Then '#.Y2021'#.kit.⎕NS'sec' 'snl' 'spl' '∆' should do.
Are you copying everything in kit?
Btw, I think your current expression could be just _←''⎕NS'#.kit.'∘,¨'sec' 'snl' 'spl' '∆'
Better question: Would it hurt to copy everything from kit in?
10:28
@Adám 50-50
WIBNI a conventional way to copy all of some kit or specific names from a kit
'cause apparently _←''⎕NS#.kit should work.
and maybe at def time you copy everything, but before you commit you use a UCMD to give you your import statement?
@Adám I will put this in all my AoCs this week for time being
@RikedyP Well, if we can get issue 18740 fixed, then ⎕THIS #.kit.⎕NS 'sec' 'snl' 'spl' '∆' is pretty nice, imo.
so Tatin's philosophy is that a package does 1 thing. So I wouldn't have my kit bag from which I choose tools which I might depend on, I would explicitly depend on each tool in the kit bag, and have the foresight to know which I'm going to need. This makes sense for the larger tools that constitute Tatin packages, and APL traditionally you'd just copy the function definitions verbatim into namespace a la github.com/the-carlisle-group/Dado/wiki/On-the-Use-of-Packages
Does it make sense to have a package dependency if the import statement is longer than the definition?
10:34
@Adám and there is something to be said about the source code all being there in one place
but I don't want to Ctrl+C Ctrl+V every time I start a function
Yes, that allows analysis, and understanding everything in a repo.
so maybe I need a UCMD that finds references to my kit bag and brings the definitions into the source in appropriate places at some point?
but then when?
For my AOC, having a kit folder isn't too bad
maybe it is just utilities in an appropriate namespace
RGS
RGS
10:53
@RikedyP thanks for the compliment :)
What I did try to figure out was a nice maths-oriented solution for yesterday. But I haven't made it yet
Because, in maths, parallel reflections can be merged.
So, I think there is a way to parse all folds first, separate the X folds and the Y folds, and boil them down.
The only issue is that the problem statement doesn't really deal with reflections, but only with "half" reflections. Still, I feel like there should be a way to merge the folds...
11:30
@FawnLocke I-beam's URL has a bookmark.
I suppose you didn'thave time to finish linking dyadic operators and syntax yet.
 
1 hour later…
12:35
0
Q: How can I label connected components in APL?

Adam NathanI'm trying to do leet puzzle https://leetcode.com/problems/max-area-of-island/, requiring labelling connected components. How can I transform something like 0 0 1 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 1 0 1 0 0 1 into 0 0 1 0 0 0 0 0 0 0 0 2 2 0 3 0 2 0 0 3 0 2 0 0 3 I've played with the stencil ⌺ op...

12:56
@RGS yeah for me it's the fudging of the size of the paper that's gonna be the piece to crack - I wonder if you condense the repeated reflections into a single transformation, and also work out the "bounds" after all the folds, then you can just ignore the points which fall outside the bounds?
 
2 hours later…
15:18
Mathsy people seemed to do the reflections and folds with elegant complex number formulations, where folds are the conjugates
16:09
@hyper-neutrino Can you give chat.stackexchange.com/users/534227/user1115629 access?
16:38
@Adám done
Thanks.
@user1115629 Welcome to the APL Orchard! Since you're new to Stack Exchange chat, please have a look at apl.wiki/APL_Orchard#Features
Hi, thank you. Was reminded that I really should learn some APL after writing a depressing amount of (vector-set! v i (+ (vector-ref v i) 1))-style code for today's AoC problem and having it suggested that maybe I should use a language that's actually good at arrays for that sort of thing.
Trying the Rosalind problems to figure out the basics but I'm having some difficulty with inputs/outputs that are fairly long - was able to get one question working with ⊃⎕NGET but even then it choked on the terminating newline initially and then I had to manually remove blank lines and indents to submit the output...
Maybe a better set of exercise problems to get the basics are problems.tryapl.org
@user1115629 You may want to use ⊃⎕NGET filename 1 so you get a list of lines.
thanks, that does make the input side of things better. don't suppose there's anything convenient like a way to copy the result of an expression directly to clipboard (without boxing/indents/extra whitespace between lines/etc)?
What OS are you on?
16:51
Win10
Then yes, you can copy to clipboard. Store your array in a variable, place text caret inside or to the right of variable name, and then from the menu, select Action>Copy Object (or click the corresponding toolbar button, which is the second one on the Object bar)
You can also do it under program control/as an expression: (⎕NEW⊂'Clipboard').Array←…
thanks! definitely says something about something that I'm spending more time trying to get I/O working than writing {'TGCA'['ACGT'⍳⊖⍵} or whatever. what it says about what, I'm not exactly sure yet ^^
hm, I appear to have lost a square bracket in the copying. oh well.
Also, I highly recommend putting backticks around your code, so backslashes and other APL symbols are not interpreted as Markdown. You can press UpArrow to edit your messages for 2 mins.
testing: {'TGCA'['ACGT'⍳⊖⍵]}
Btw, you can execute APL right here in the chat: ⎕←{'TGCA'['ACGT'⍳⊖⍵]}'AGCCTGCACGTA'
17:03
@Adám TACGTGCAGGCT
is there any way to get ⎕NGET to use a relative path instead of absolute? (or, at least, if it does use a relative path, it doesn't start in the folder my .dws file is in...)
It is always relative… to the current directory. You could change the directory you start APL in (hint: change the shortcut) or change the current dir from inside APL with ]cd targetdir
thanks!
Any time (almost).
17:23
is there an interesting historical story/reason why works how it does?
@user1115629 You mean why one symbol with a selector argument instead of dozens of symbols?
yeah. or selecting with a name, for that matter, 'sin' ○ ○0.5
@user1115629 Look at all three occurrences of "circular" here.
One of the reasons is that it is a scalar function and most APLs have no scalar strings. That said, the A+ dialect did have "symbols" and allowed `sin as left argument, but numbers were recognised to be faster.
thanks. unrelated and let me know if I'm asking too much random stuff but. is this reasonably idiomatic or did I miss a better way? count ←{+/⍺∊⍵} and then basecount ← {⍵ count⍤1 0⊢'ACGT'}
@user1115629 Oh here is the real source.
@user1115629 It is reasonable, but better is basecount←{+/'ACGT'∘.=⍵} or {+/'ACGT'=⍤0 1⊢⍵} if you prefer.
17:39
oh, I hadn't realized that 'A'='ACGT' would be 1 0 0 0. Which I really should have.
17:51
@user1115629 Don't worry – keep asking. I'm always happy to answer. Although for fastest answers, you might want to check aplcart.info with simple questions.
 
1 hour later…
18:54
For problem 2 on the problems.tryapl site you linked, are you meant to do it without using ⍳?
@user1115629 Which year/URL?
You can/should use .
 
1 hour later…
20:06
@Adám I'm able to run Ride on WSL2 in Windows 11 but I will get the following error message [14197:1214/215604.144917:ERROR:buffer_manager.cc(488)] [.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command. What should I do?
@kimmolinna Where do you see this error message?
@Adám In terminal.
So APL quits and you see this in the terminal?
@Adám No. APL is running but I will the error message in a terminal when I start a session. Later on I will get some dconf error messages in terminal.
@kimmolinna But everything (APL & RIDE) is otherwise working?
20:15
@kimmolinna You are running RIDE as a Linux GUI application under Windows? In the short term, you might try running RIDE under Windows instead. Unfortunately this means you need to know the IP address of the WSL system, which will change at each boot.
I don't know that anyone at Dyalog has tried running the Linux RIDE under WSL
Aha, this is an Electron issue.
So yeah. Probably an incompatibility between Linux Electron and the GUI parts of Win11's WSL2.
@MortenKromberg This was my first plan. ;)
@kimmolinna If you log an issue at github.com/Dyalog/ride/issues I'll poke the developers, but I'm not sure how easy it is to fix.
Hi, I started writing a site just with static files (HTML, CSS and JS) to host it on GitHub Pages. I wanted to execute APL functions within JS, but couldn't figure out how. I think that one way could be use tio.run, but couldn't understand how it convert the data. Any idea, or other alternatives?
@MasterQuiz You could use the TryAPL API.
20:32
@MortenKromberg No need anymore - export LIBGL_ALWAYS_INDIRECT=1 in .bashrc worked
@kimmolinna But maybe that can be built in or at least documented.
For the FRC problem, I imagine this was not what I was meant to do - would like some advice on improving it. {(1=(⍸'R'=⍵)⍸(⍵⍳'K'))∧2|+/⍸'B'=⍵} (Problem: problems.tryapl.org/psets/…)
@Adám That's true. I will do an issue on GitHub.
@kimmolinna Thanks!
@user1115629 That's a fine solution. I'd maybe swap the arguments of to even out the parenthesis levels, but that's really minor. Btw, there'll soon be a commentary blog post coming out about those problems.
20:45
fair enough, it feels a little unreadable and also a little long to me, but maybe that is just not APLing enough
@user1115629 I think {(≠/(⍸'R'=⍵)<⍵⍳'K')∧(≠/2|⍸'B'=⍵)} was my solution.
But the blog post will have many more, and more interesting solutions. Look forward to that.
is there a function like ⍴ except that instead of repeating it just uses 0s for extra cells? (e.g. 3{...}1 2 becomes 1 2 0)
@user1115629
(but only for vectors)
@Adám Ohh yes, I've completely forgot about it... But are there some source about it? On aplwiki.com there are only an example and in the Webinar, Richard doesn't talk a lot about it
oh, neat. got tricked by the name into thinking it wouldn't like a larger left argument than the length of the right argument
20:59
@user1115629 A general solution is {⍺⍴⍵,⍥,⍺⍴0}
I'm not sure I have a clue what ⍥ is. (in fact I'm fairly sure I don't)
ahh I was reading that as {(⍺⍴⍵),⍥,(⍺⍴0)} and then getting confused why it didn't do the same thing as that
Ah, I can see that, due to the (apparent) symmetry.
 
2 hours later…
23:01
@MortenKromberg I was able to set up ssh on WSL2 so that it starts automatically on log on so I don't have to know any ip addresses. I can start Ride from localhost and It's starts an interpreter from WSL2 (/opt/mdyalog/18.0/64/unicode/mapl). It's easier like this because now I can use Dyalog APL IME on Windows. It's not working if I start Ride directly on WSL2.
@MortenKromberg I will write down the instructions tomorrow....
Awesome. Thank you so much!

« first day (1784 days earlier)      last day (1167 days later) »