« first day (1162 days earlier)      last day (1789 days later) » 

00:00
@Bubbler Only a two-liner in the absence of … Should've been (⊃+⌈/)∘|-⍥{{⍵+1|⍺}\0.5 1ׯ1+0 100⊤⍵}
@Adám Yeah, true.
 
9 hours later…
09:29
@Bubbler - Nice! And a good explanation, too! Thank you!
@dzaima Oh, but only monadically ⍨
09:48
@ngn Any idea why this gives a SYNTAX ERROR in ngn/apl?
perv←{⍺←⊢               ⍝ Scalar pervasion
    1=≡⍺ ⍵ ⍵:⍺ ⍺⍺ ⍵     ⍝ (⍺ and) ⍵ depth 0: operand fn application
             ⍺ ∇¨⍵      ⍝ (⍺ or) ⍵ deeper: recursive traversal.
}
NonScalarFn←{⍵:'t' ⋄ 'f'}
NonScalarFn perv (0 1) 1 (⊂1 0)
@Adám no ⍺←⊢ because static type evaluation?
huh, i recall this or something similar evaluating things out-of-order. Either way, ⍺←⊢ alone is enough to make ngn/apl syntax error
@Adám right, that's what i needed at the time. Dyadic case is much more challenging, and i haven't noticed any worthwhile use-case for it
@dzaima ah, it was this
ngn
ngn
10:24
@Adám as dzaima said
@ngn Any way to define an ambivalent fn?
ngn
ngn
@Adám monad⍠dyad
@ngn Ah, but that means no way to define an operator which can handle ambivalent functions, right?
ngn
ngn
@Adám yeah, i thought there were more important problems to be solved in apl first - the lack of first-class functions being the most prominent
 
2 hours later…
12:18
Is there a way to recover from WS FULL?
12:39
@Adám - ⍥ is notionally what?
12:52
As I mentioned a few days ago, I tried to use APL to solve the sliding tiles puzzle. @ngn showed me an elegant way to generate the valid moves. I now have something that works, up to a point: gist.github.com/xpqz/550d032db953bc7f0d87bc8fd136ec5f
It finds the solution for a 2x2 puzzle, but for a 3x3 it basically never finishes.
My solution is clearly epically inefficient in APL.
:53960262 Over operator ⍥←{(⍵⍵ ⍺)⍺⍺ ⍵⍵ ⍵}
I rewrote it in Python here gist.github.com/xpqz/fdb6abddbab4a7681e9a7dca81f22c92 and it finishes in <1.0s.
The potential search space is moderately large but not massive (~180k states).
The solve function is a small tweak of the bfs function from the dfns ws.
@RichardPark - Thank you!
ngn
ngn
@xpqz */⍴⍵ - did you mean ×/⍴⍵?
:D
oops
Let me quickly try that.
13:12
@xpqz APL won't actually let you overfill the workspace. It'll stop at the statement that would do so.
@ngn fixed that, but it stll seems to run and run.
ngn
ngn
13:28
@xpqz tio
i shortened your code a bit in order to fit the tio link in a chat message
Cool. Suspect not the last time I pick * instead of × for multiplication.
@ngn think the 3::⍺ can go, too.
ngn
ngn
@xpqz yeah, and many things can be shortened :)
13:44
I fully expect that could be golfed to a 10th of its current size.
Baby steps.
@Adám - Indeed he does!
14:37
@Adám - I've encountered interpreters for other languages that would do this; does Dyalog?: If the workspace/session is getting full, save it and reload it - that forces a garbage collection, which lets you work some more.
14:52
@JeffZeitlin you can force garbage collection by calling ⎕WA
@dzaima - Good to know, although the question was less about how to force gc than about whether doing so, by hook or by crook, would allow one to continue to work after getting WS FULL (following up on @xpqz's comment).
@JeffZeitlin Dyalog always allows continuing work after a WS FULL, as long as that work doesn't involve filling up the memory again
@JeffZeitlin Do ⎕WA to compact the workspace.
@Adám - Yes, got that from @dzaima. I haven't actually hit the need; it was triggered by @xpqz's comment about WS FULL earlier.
 
1 hour later…
16:29
@Adám - What's the (source code) compatibility between Dyalog and NARS2000? Mostly, I'm interested in knowing what to avoid using in either if I want to write code that will run in both.
 
1 hour later…
17:32
@JeffZeitlin afaik NARS2000 implements most of ⎕ML←3 Dyalog, but adds many additional features (also NARS2000 only does ⍣¯1 for some special cases)
@dzaima - So if I stick to straight Dyalog and mostly avoid ⍣¯1, I should be OK?
@JeffZeitlin i'd not call ⎕ML←3 "straight Dyalog". Also no and in NARS2000
@dzaima OK, I see what you're saying. ⎕ML←3 differences also includes those from ⎕ML←2 and 1, correct?
@JeffZeitlin seems that way
RGS
RGS
18:01
Hey there, I ran this code
(⍳8) {⍺':'⍵}⌸ ⍳8
And it created a neat little table
@JeffZeitlin Obviously, the unique Dyalog functions and operators, as dzaima mentioned, but also things unique to NARS2000 like π .. and the many constant notations. NARS2000 also requires and depends on explicit mention of dfn arguments, so you can't do {⎕←?4}¨⍳3 as that dfn is niladic (!). NARS2000 has some system labels that Dyalog doesn't have, etc. etc.
RGS
RGS
So does ⍺':'⍵ implicitly convert the integers into strings and concatenates everything?
@JeffZeitlin Of course, the sets of system functions are not very compatible at all.
@RGS Yes, but those arguments are not very good for figuring out what does.
RGS
RGS
@Adám I'll keep exploring!
@Adám - Yes, I was just checking out some of that. For the most part, the project I have in mind is more-or-less vanilla APL - most of it would probably be doable without much difficulty on that IBM5150 emulator, if I do dfns as tradfns - so I just wanted to be sure that there weren't going to be any real GOTCHAs.
18:06
@JeffZeitlin I'm not sure what scoping NARS2000 uses, but if you do advanced stuff and try to convert dfns to tradfns or vice versa, you might hit differences there.
/me nods
RGS
RGS
18:28
@Adám I have a question about what "If X is specified, it is an array whose major cells specify keys for corresponding major cells of Y. The Key operator ⌸ applies the function f to each unique key in X and the major cells of Y having that key." means, in the docs about ⌸
I guess I don't understand what the "major cells" are
@RGS The major cells are simply the subarrays of rank one less than the whole array's rank. I.e. scalars of a vector, vectors of a matrix, matrices (layers) of a 3D array, etc.
@RGS I can't promise everything is defined quite yet, but if you wonder what a term means in APL lingo, try APL Wiki. E.g. Major cell. If you fail to find something, let me know.
RGS
RGS
Is it another pet project of yours? :)
@RGS Me with another couple of people, including RichardPark.
RGS
RGS
nice!
Say I'm using 4 1 ⍕ Xs to format some percentages with 1 decimal place
Is there a neat way of ommiting the .0 when they happen?
say, to display 50 instead of 50.0
@RGS Are you sure you want 4 1 ⍕ Xs and not just 1 ⍕ Xs ? The 4 causes a fixed text width result.
@RGS Does ⍕ ⍎ 1 ⍕ Xs work for you? It doesn't force field width to 4 though.
RGS
RGS
18:37
@Adám I was using the 4 to keep the results aligned
@RGS Does ⍕ ⍎¨ 1 ⍕¨ Xs do that?
RGS
RGS
Is the ⍕ ⍎ doing something like "convert the strings into numbers and then into strings again"?
@RGS Yes, exactly. Btw, if doesn't give you enough fine-grained control, have a look at the very powerful (but somewhat complicated to learn) ⎕FMT.
@RGS For this particular case, you could simply do '\.0'⎕R' ' ⊢ 4 1 ⍕ Xs no?
 
2 hours later…
RGS
RGS
20:56
@Adám You are getting into really weird formatting things :P I was trying to understand if there was something really short and obvious I was missing; I doubt I need to go into the detail you are going into.
Either way, I'll remember in the future that ⎕FMT exists o/
@RGS Well, when you're doing something inconsistent, the code will be involved :-)
RGS
RGS
@Adám What do you mean by "inconsistent"? Mixing integers and floats?
@RGS Yes, well, formatting some numbers with a decimal and others not.
RGS
RGS
yeah makes sense
and is (⊂∘⍋⌷⊢)Y really the shortest you can do to sort something in ascending order..?
(as per the APL cart when I query with "Sort")
@RGS If a vector, {⍵[⍋⍵]} and (⍋⊃¨⊂) work too, and if you're sorting a vector already in a variable z you can do z[⍋z].
RGS
RGS
21:03
for the final one, wouldn't it be z[⍋z] ?
@RGS Yes, typo — fixed.
RGS
RGS
:)
@RGS But yes, you're hitting one of the uglies. With sane indexing as you'd write (⍋⊇⊢) or ⊇⍨∘⍋⍨
RGS
RGS
(⍋⊇⊢) this is tacit, right?
the 3 glyphs are acting as a single function? And then you use () to group them?
It is. Correct.
@RGS (⊂∘⍋⌷⊢) is tacit too. (Just checking that you don't misunderstand something.)
RGS
RGS
21:07
@Adám yes; but you didn't use that one up there; on the other hand, you used (⍋⊃¨⊂) which is also tacit, right?
Yes. It is not so hard to identify tacit APL. If the rightmost (bordering the end of the parenthesis or the statement) token is a function, you've got yourself some tacit code.
You don't actually need the parenthesis for stand-along tacit functions. They are just for clarity. The following is perfectly valid:
Sort←⊂∘⍋⌷⊢
Sort 'abracadabra'
RGS
RGS
Makes sense; evaluation is from right to left and you can't really evaluate a function without arguments so if the rightmost "thing" is a function then the whole thing is a function. Is this reasoning ~accurate?
perfectly
RGS
RGS
@Adám the challenge is in understanding where I need to use ∘ between glyphs
@RGS This may interest you. You basically need (and possibly parentheses) whenever you need multiple functions applied monadically.
RGS
RGS
21:15
Oh boy, 1h is too much for right now haha
well, problem 3 from '19 really is "inconsistent" then, as they want my 30.0 to really be a 30
just fixed it, I think
@RGS No, the default display form chops trailing zero decimals. That was the trick I used above with ⍕ ⍎ 1 ⍕ Xs
RGS
RGS
@Adám Sorry, I did not understand what you mean. Probably I expressed myself badly..?
When I used ⍕ ⍎ 1 ⍕ Xs the 30.0 displayed as 30.0
Or maybe I made a mistake running the code?
 grade_distribution←{
     len←≢⍵
     sorted←⍵[⍋⍵],'ABCDF'
     summarize←{⍺,(1-⍨≢⍵),⍎1⍕100×len÷⍨1-⍨≢⍵}
     summarize⌸sorted
 }
This is what I used :) I wanted to know what you think about that cheap trick I did there, appending 'ABCDF' to the grades I get and then subtracting 1 when I'm summarizing them
Do you want context / a link to the problem I'm talking about?
@RGS That shouldn't happen. Doesn't ⍕ ⍎ 1 ⍕ 1.90 1.99 2.11 give you 1.9 2 2.1 ?
RGS
RGS
@Adám Yes it does... But for some reason (I was sure) it gave 30.0 for 30.0... maybe I didn't fix the code properly.
@RGS Nice that you figured that out! That is indeed the common method to force inclusion of 0s.
RGS
RGS
21:29
@Adám oh so that is what you would do? Because I feel it is not really that elegant
@RGS It really isn't. A gripe I have with ;-)
@RGS Rather than using conversion to and from string to round, you can use ⌊0.5+number but first multiply by a power of 10 to make the rounding happen at the right magnitude.
RGS
RGS
@Adám it took me a while to understand what "gripe" was... That is a portuguese word and it is related to the coronavirus, so I was really confused.
:-D Sorry.
@RGS Instead of computing 1-⍨≢⍵ twice, you can give it a name inline. APL's assignments always have a "pass-through value" identical to whatever is on the right of , so {⍺,count,⍎1⍕100×len÷⍨count←1-⍨≢⍵} would work.
RGS
RGS
But doesn't that make the code a bit more hard to digest? Even though re-computing things isn't exactly efficient...
@RGS Possibly, but with your style, you could write:
 grade_distribution←{
     len←≢⍵
     sorted←⍵[⍋⍵],'ABCDF'
     summarize←{
         count←1-⍨≢⍵
         ⍺,count,⍎1⍕100×count÷len
     }
     summarize⌸sorted
 }
RGS
RGS
21:39
face palm
of course, that looks good; I like it
@Adám along the way, please give me style tips as well
I try to be consistent and I think I actually am consistent. And I like to write elegant code.
@RGS Yours is already nice.
RGS
RGS
But elegance depends on the viewer, of course; but also on the language itself.
I'm porting what I usually use with Python to APL
for example, one thing that annoys me a bit is that the Dyalog interpreter collapses whitespace I use
Is that for a particular reason?
@Adám Thanks! But I'm up for all sort of tips
It is because it stores the code in tokenised form. If you start off with code in text files, it'll use the exact spacing you used. There's also a trick you can use to make it remember your spaces: Use 2⎕FIX to create the function. Once created, you can use the regular editor to modify it and whitespace will be preserved. So, e.g. to create and edit the function Foo, just do ⎕ED 2⎕FIX,⊂'Foo'
RGS
RGS
Now that it is in the tokenized form, can I do anything thing to save it decently?
Other than creating a new file, of course.
You mean you've inserted spaces in the editor, but you know that if you save/close now, you'll lose them?
RGS
RGS
21:54
Yes, because that is what has been happening. I usually start with )ed foo then edit foo, press ESC, test, type )ed foo, etc etc
but the spaces are not preserved.
^ this space-removing thing is why i never use the in-Dyalog editor when making >10 char functions. I really like my whitespace as it is. Sometimes i just write in a text file and copy-paste to the )ed window :p
@RGS So you have to remember to use my trick. You can even stick it into a function. If you find yourself in the editor having already written a lot of stuff, select everything and copy to clipboard, escape the editor, run that definition expression or function, then paste.
@dzaima You can use my trick too. I was so surprised when I stumbled upon it.
That trick might be worth incorporating into a user command ]edit?
@Adám if only there wasn't the window popping up on every save. but i guess it's already many times better than whatever i've been doing
@dzaima What window?
RGS
RGS
22:01
@Adám Works like a charm!
Here's a function you can always use to edit functions and operators while preserving whitespace:
Ed←{⎕ED 2⎕FIX⍣(0∊⎕NC⍵),⊂,⍵}
RGS
RGS
I just like how APL feels so "meta" with all these ⎕ things
Maybe I should add this function to APLcart?
Unfortunately, it doesn't work for objects or names in objects.
RGS
RGS
@Adám yes
@Adám ah, i first tried using 2⎕fix'test' which told me to make a file. what you were describing was another, even more obscure way to do an even more useful thing :|
RGS
RGS
22:03
But it is something that is hard to search for, isn't it? I would never go to the APL Cart and type "HALP, my whitespace is being eaten"
@RGS But maybe just "whitespace" or "preserve/keep/save/remember whitespace"
if the interpreter can preserve the whitespace just fine, why doesn't it always?
RGS
RGS
@Adám sure
That is definitely more sensible than "HALP, my whitespace is being eaten"
@dzaima Firstly, it is a (relatively) new feature, and traditional Dyalog programmers are used to the auto-formatting. Secondly, it requires additional memory to keep it:
      ⎕fx,⊂'foo'
      2⎕fix,⊂'goo'
      ⎕size'foo' 'goo'
320 384
@Adám it indeed seems new - no mention of it here; also, how does anyone live with automatic space formatting?!?!?!
22:09
Now you might say that this isn't much memory, and memory is cheap, but I know of APL applications that consist of close to 100000 (10⁵) functions.
@dzaima ah, ignore the first part, was looking at the wrong page.
There also isn't much support for the feature. E.g. ⎕NR/⎕CR/⎕VR will return the detokenised form, not the actual source, and there's currently no way to get the actual source under program control. We're working on that though; it should probably be ⎕SRC.
22:29
@dzaima @RGS Here's a full whitespace preserving cover for ⎕ED:
 Ed←{
     ⍺←'∇'
     1≠≡,⍵:⍺ ∇¨⍵
     (0∊⎕NC ⍵)∨⍺∊'⊢∊-':⍺ ⎕ED ⍵ ⍝ exists or text: as-is
     '∇'=⍺:⎕ED⊃2 ⎕FIX,⊂,⍵
     t←'Namespace' 'Class' 'Interface'⊃⍨'⍟○∘'⍳⍺
     ⎕ED⊃2 ⎕FIX(':',t,' ',⍵)(':End',t)
 }
RGS
RGS
bloody hell
⎕ED 2⎕FIX,⊂'Foo' is much easier to remember :-P
@RGS Just make sure the name is a vector. You may want to remember it as ⎕ED 2⎕FIX,⊂,'Foo'
RGS
RGS
@Adám What do you mean?
@RGS If you try to create a function named F with ⎕ED 2⎕FIX,⊂'F' it will fail because 'F' is a scalar, not a vector.
RGS
RGS
Oh and the extra , you included covers that case; is that it?
22:33
Yes.
@RGS Yeah, too big for APLcart.
RGS
RGS
@Adám Say ⍴ X is 2 2
and I want it to be a vector of pairs
first, what is the difference between being a "column" of pairs or a "row" of pairs?
I am assuming the major cells will differ in both cases; I am interested in knowing which cells will be the major cells in every case.
@RGS Not sure, could be the transpose, or simply 1 2⍴ vs 2 1⍴
@RGS Apply monadic (it points down because it lowers the rank by increasing depth)
RGS
RGS
I applied 4 1⍴ X because that is more what I want
I was just wondering if there was a more suitable thing
I don't know what you're doing.
RGS
RGS
or a more general one
22:41
@RGS Like monadic ?
RGS
RGS
@Adám (¯1 1)∘.,(¯1 1) creates a 2x2 matrix of pairs
But before your edit, monadic , did exactly what I wanted
@RGS OK, but that simply ravels to a vector. 4 1⍴ would create a 4-row 1-column matrix.
RGS
RGS
@Adám I am probably still struggling with the distinction between vectors and matrices.
I wanted to have all combinations of +/- 1 in pairs and there are 4 of those
And I wanted to have some data structure that I could traverse in a single direction and that, upon indexing, would give me one pair of those.
, did just that
And so did (4 1 ⍴)
@RGS I'm not sure 4 1⍴ would have been good for indexing later. 4⍴ would have worked though.
RGS
RGS
but (1 4 ⍴) did not give what I want, because then 1 ⌷ 1 4 ⍴ signs gives the whole thing
@Adám you are right; it produced one extra dimension
22:49
@RGS That's because 1⌷ would select the first row of the 1-row matrix.
RGS
RGS
Yes.
temp ← 4 1 ⍴ ((¯1, 1)∘.,(¯1, 1))
1⌷1⌷temp
produces ¯1 ¯1 with a box around it
But 1⌷1⌷1⌷temp doesn't give ¯1
@RGS Yes, every element is enclosed by ∘.,. Here's a mathematical alternative:
RGS
RGS
So what is ¯1 ¯1 with a box around it? I thought it was a vector.
temp ← ¯1 * ⍉ 2 2 ⊤ ¯1 + ⍳ 4
1⌷temp
@RGS It is a scalar whose only element (scalars only have one element) is a 2-element vector.
Use ¯1 * ⍉ ~ 2 2 ⊤ ¯1 + ⍳ 4 if you want the same order as yours.
RGS
RGS
@Adám I do not understand this statement.
22:55
@RGS ∘., has to apply , between all combos of elements from left and right argument, creating a new 2-by-2 array. But each application of , gives a 2-element vector, so each scalar element of the result matrix has to itself be a 2-element vector.
RGS
RGS
Ok your explanation makes sense
@RGS Btw, do you really need that table? Couldn't you just compute the pair directly from the index?
¯1 * ~ 2 2 ⊤ n - 1
RGS
RGS
But it bothers me that, after accessing an element of said 2-by-2 array, I can't index into that as a regular vector.
@RGS You need to open the box ("disclose the scalar") with
RGS
RGS
@Adám ah wow, thanks
22:58
@RGS You could use n ⊃ , ¯1 1 ∘., ¯1 1 directly. (I took the freedom to remove unnecessary ,s and parens.)
Also, you can avoid repeating yourself with n ⊃ , ∘.,⍨ ¯1 1
RGS
RGS
@Adám I have the habit of using commas in "lists", as most programming languages use them
@Adám I like this
What is the difference between dyadic ⊃ and dyadic ⌷?
@RGS "eXtracts" (it is on the X key) the contents of a particular element (or element's element, etc.), while just fetches the element (or cell, really).
RGS
RGS
"just fetches" means "gets a reference", in a computer memory sense?
@RGS No, everything is pass-by-value (except objects). It just returns the cell without "unboxing" it.
RGS
RGS
Ok, so without "opening the box" like you said above?
23:06
Exactly. Same as if you used the square brackets. ( is in fact just `[] squished together.)
RGS
RGS
("No, everything is pass-by-value (except objects).", I think you had already said that to me.)
Ok, I understand now.
In code: 1 2 ≡ 1⊃(1 2)(3 4), (⊂1 2) ≡ 1⌷(1 2)(3 4)
RGS
RGS
@Bubbler Thanks! That confirms I understood
Thanks for your help; I am off to bed now, tomorrow I'll finish problem 4'19 on the knight moves :D
Sleep well.
RGS
RGS
Thanks! You too.
23:49
@RGS Added

« first day (1162 days earlier)      last day (1789 days later) »