« first day (1267 days earlier)      last day (337 days later) » 

⍉⁼⌽ in BQN.
And the non-inverse form ⍉⌽ would work equally well.
 
@Marshall So BQN's cycles through the axes by default?
 
@Bubbler Yes.
 
1:54 AM
... it was already done 4 years ago
 
 
3 hours later…
5:17 AM
@Bubbler Ah, so I can now shorten (⌽2 3 1⍉,)⍣6 to ⍉⍤2⍤⍉⍤⌽⍤,⍣6
 
@Adám So many faces!
 
5:31 AM
Also, it'd be ⌽∘⍉∘,⍣6 and ⌽∘⍉∘,⍟6 in APL' and BQN.
 
5:43 AM
Actually, ⌽⍤⍉⍤,⍣6 in APL'
 
 
3 hours later…
8:40 AM
In the unlikely event someone's interested, I've now finished AoC 2017 (after '16 and '15): nbviewer.jupyter.org/github/xpqz/AoCDyalog/blob/master/… -- they get harder.
 
@xpqz Cool stuff. We're just discussing creating a library (in the municipal/university sense) of media publications such as this.
 
I've found the problems a perfect size for learning with a gradual difficulty ramp-up.
nbviewer doesn't do an awesome job rendering APL, which is a shame.
 
RGS
9:16 AM
@xpqz good job!
 
ngn
@xpqz nice, but why jupyter when plain text would do?
 
@xpqz What do you mean? It looks fine to me, other than the syntax highlighter being out of date (and thinking _ is an error).
@ngn Jupyter Notebook allows you change things and re-execute for experimentation.
 
ngn
@Adám and plain text doesn't?
 
No.
 
ngn
@Adám explain pls?
 
9:24 AM
No.
 
ngn
:)
 
10:15 AM
@Adám It puts red boxes around some glyphs, and glyph sizes seem to vary. For example is both tiny and red-boxed.
 
@xpqz "the syntax highlighter being out of date", i.e. it is pre-16.0.
 
@ngn I know, right? But I find the notebook interface nice to be able to scroll back, re-execute a single cell -- and I like being able to mix prose with code in a nice-looking way.
 
@xpqz fyi, ngn doesn't care about things like "nice interface", "going back", "prose", or "nice-lookingness". Source: personal experience.
 
RGS
@Adám 🙃
 
I respect that. I think both approaches have their place.
 
ngn
10:26 AM
@xpqz "I know, right?" - right, your code is none of my business, but i happen to be doing a similar thing with aoc and i thought i should share experience and challenge assumptions. i find that self-testing code in a plain-text file works best, so i was curious what pushed you to something as complicated as jupyter.
 
@ngn My description of you is accurate, right?
 
ngn
@Adám it's funny :)
 
Absolutely. Part of it was my inexperience when I set out: I couldn't figure out a convenient way to arrange Dyalog code into a "script" as I would with (say) Python (github.com/xpqz/aoc-19/blob/master/day05.py). The closest I found was Jupyter. But part of it also was that a Jupyter notebook reads like a blog post, following e.g. Peter Norvig's many examples (github.com/norvig/…) -- a sort of executable documentation.
@ngn I've seen your k-examples (which are inspirational) - and I'd be interested in how a workflow could work for Dyalog in a similar manner.
 
ngn
@Adám i don't care about prose because it's verbose but sometimes my code rhymes
 
I have no intrinsic love for Jupyter per-se -- it's hopeless to version properly, and it will inevitably reach an inconsistent state if you jump around in it and execute cells out of order.
 
RGS
10:35 AM
I wonder if you could help me figure out how one could write the pattern (⍺ g (⍺ f ⍵)) h (⍵ g (⍺ f ⍵)) as ⍺ train ⍵, if it is at all possible. all f, g, h are commutative
I guess I could pre-compute v ← ⍺ f ⍵ and do ⍺ h⍥(g∘v) ⍵ but I really wanted to know if the whole thing could be written as a train
 
ngn
@Adám "nice interface" etc - maybe yes, simpler is better. what do you mean by "going back"?
@xpqz just put this at the top of the file, chmod +x it, and run it:
#!/bin/bash
dyalog -script <(echo ∇M;tail -n+3 $0;echo -e '∇\nM\n⎕off');exit $?
⎕←''
@xpqz some golfers will disagree, but i also like writing self-testing code that prints in a clear way whether the tests passed or not
 
@ngn Changing existing code instead of rewriting.
 
ngn
@xpqz writing a line of code with the expected result as a comment (like you do in jupyter), reevaluating, and comparing manually is not good enough for me
 
@ngn Will that allow me to write multiline dfns in the file (assuming that a multi-line dfn isn't already a personal fail :))?
 
@xpqz I can help you with that.
 
ngn
10:44 AM
@Adám oh, i do that a lot, of course. i do many iterations over the code, in some cases spending hours on a single line. but if you have a big complicated system - yes, rewriting is better than getting more and more entangled in legacy
@xpqz yes
 
@ngn You're right, of course - it's a bit lazy of me - and at some stage I'd like to understand better how APLers approach testing 'the right way'.
 
ngn
@xpqz n aplers, n+1 opinions
 
@ngn Can you explain this code to me? I might be able to help you improve it drastically.
 
ngn
@Adám dyalog -script requires a filename. in bash <( ) captures the output of something and makes it pretend to be a file
 
@ngn Right, but the content of that parenthesis is what I don't understand.
 
ngn
10:49 AM
echo ∇M etc surrounds the script in a tradfn so multiline dfns can be possible
 
Ah, and then you call M and quit.
 
ngn
yup
 
And tail -n+3 $0?
Takes this file except the first three lines?
 
ngn
⎕←'' because for some strange reason dyalog -script prints a prompt
 
The first three lines is the bash bit, skipped by the -n 3
 
ngn
10:50 AM
@Adám yes
i posted it here when i upgraded to the latest dyalog, btw
so, this #! thing + a shortcut in my editor to exectue the current file = very convenient, instant feedback, no need for repl
 
@ngn Is it possible to put that something into a temporary file?
 
ngn
@Adám i think that's what <( ) does
 
@ngn Right, but I need the filename.
 
ngn
<( ) gets replaced with the filename. you could do it manually:
#!/bin/bash
(echo ∇M;tail -n+3 $0;echo -e '∇\nM\n⎕off')>/tmp/a;dyalog -script /tmp/a;exit $?
(; separates bash statements)
 
@ngn Right, ok, now if you add DYALOG_LINEEDITOR_MODE=1 to the command line, then you can remove the tradfn wrapper and I think ⎕OFF too. You may want to 2>/dev/null too.
 
11:00 AM
@ngn if you're doing the AoCs, at some stage maybe I could pick your brains on some bits I found I had to reach for tradfns in order to solve, or were otherwise inelegant or inefficient?
 
Just remember that you have to be explicit about output: ⎕←
 
ngn
@Adám tradfn wrapper - right, thanks
⎕off can be removed too
2>/dev/null breaks ⍞←
 
@ngn Right, but I think there's an issue with APL printing 6 spaces everywhere if you don't.
@ngn And now you can use tradfns and scripted objects too.
 
ngn
@Adám it does it only once or twice in the beginning - that's why i put ⎕←'' on the third line
 
@ngn I need to make John have -script disable 6-space prompts (except for ).
 
ngn
11:07 AM
also: error codes don't work
 
@ngn You mean exit code?
 
ngn
@Adám right.. whatever they're called
should be ≠0 if there's an error
 
@ngn Right. I'd inject ⎕TRAP←0'E' '⎕OFF(128⌊⎕EN)' at the top of the script.
 
ngn
@Adám it works, thanks
 
@ngn Can you post your full bash template here for others to enjoy?
 
ngn
11:11 AM
@Adám sure but the problem with ⍞← remains
#!/bin/bash
DYALOG_LINEEDITOR_MODE=1 dyalog -script <(tail -n+3 "$0") 2>/dev/null;exit $?
⎕trap←0'E' '⎕off(128⌊⎕en)'
 
@ngn Right, [John]'ll try to get to it soon
This is issue 18245 (for future reference).
 
ngn
@Adám this is too complicated for users though. why not make #!/usr/bin/env dyalog possible? (a fight i started 6-7 years ago)
@xpqz sure!
 
@ngn We are getting there. I expect 19.0 to do allow that, and version 20.0 to even have multi-line array notation in such scripts.
@ngn Can you not make an executable that takes a file name and injects this stuff, and runs it, so your scripts can say #!/usr/bin/env dyalogs ?
 
11:33 AM
@ngn Is it possible change the stderr redirect into piping it through sed?
 
ngn
i'll be back in half an hour, sorry
 
No problem. I'll keep babbling, and you can reply later.
 
11:58 AM
@Adám I'm about (finally) to upgrade to 18 -- will I need to reinstall the jupyter kernel for it to pick it up?
 
@xpqz I think it always uses the newest available Dyalog, but reinstalling (just run the install script) can't hurt.
So I was thinking something like /env/bin/dscript:
#!/bin/bash
DYALOG_LINEEDITOR_MODE=1 dyalog -script <(echo "⎕trap←0'E' '⎕off(128⌊⎕en)'";tail -n+1 "$1") 2>&1 | sed "s/^\( \{6\}\)*/"
exit $?
Sorry, I meant /bin/dscript without env/
And then a script could simply say:
#!/bin/dscript
⎕←4{
  ⍺⍴⍵
}2
However, I'd like to only strip sixtuple-spaces from stderr, leaving stdout alone.
 
@Adám sed: 1: "s/^\( \{6\}\)*/": unterminated substitute in regular expression
You're missimg a slash
 
Ah, yes.
 
Also: won't work on a Mac :/
 
Because?
 
12:12 PM
Dyalog don't install inself in a normal unixy place on a Mac it seems.
/usr/local/bin/dscript: line 2: dyalog: command not found
One for the v19 wishlist.
 
Wait what? How does one start APL then?
 
Double click on the RIDE icon :)
Last login: Mon Jun  8 08:33:09 on ttys001
(base) Stefans-MacBook-Pro:~ stefan$ which dyalog
(base) Stefans-MacBook-Pro:~ stefan$
 
@xpqz Can you not get properties of that icon to see what it does?
 
Well, I can see the Dyalog-17.X.app contents, but that's the RIDE app, right? I am unsure how it spawns the 'terp
 
Hm.
 
12:20 PM
Ah.
This is what it does:
#!/bin/sh
cd "$(dirname "$0")"
D="$(pwd)"
cd
export RIDE_SPAWN="$D/../Resources/Dyalog/mapl"
exec "$D/Dyalog-17.1" "$@"
So it's very packaged up/
 
@xpqz There could be two different dscripts one for mac and on for other UXs.
 
It would have been nice if the interpreter just lived in /usr/local/bin as (I guess) it does on linux
No reason it shouldn't
It's installed here:
/Applications/Dyalog-17.1.app/Contents/Resources/Dyalog/dyalog
Not great (imho) if ever heading towards more support for scripting
 
Can you write support@ and complain about that?
 
Sure -- although the situation can of course be somewhat remedied with a symlink.
 
Right, but our installer could set that up, rather than leaving such dirty work to the poor user.
 
12:46 PM
Ok, fwiw - mail sent. I suspect Dyalog's Mac userbase is small (maybe just me).
 
12:56 PM
The macOS version is the most recent addition to the supported platforms and the user base is indeed small. Historically APL users have either been "financial" (=Windows) or "technical" (=UNIX). The way we package APL on under macOS is coloured by the fact that this is supposed to be an environment for "end user computing", rather than technical.
Many of the current users of Dyalog APL came over recently from MicroAPL / APLX.
That being said, macOS is growing in importance and your points are good ones, so thanks for your input.
I am happy to be able to tell you that we are about to release version 18.0 "Issue 2", which is notarised and, as far as we can tell, a good citizen of the Catalina world. If all goes well that will be next week and we will make it available both commercial and non-commercial users.
 
@MortenKromberg Hi Morten -- thanks for taking the time to respond.
 
@xpqz My pleasure - thanks for pushing!
 
How about the crypto library on MacOS :)
 
So... that is some way down the priority list, I'm afraid. I'll have a word with the developer when he gets back from holiday to hear how hard it is. Can you send me an e-mail message with a few words about why it is important to you?
@Marshall Hi Marshall - any chance of a "Rosetta Stone" version of this page, with the original APL alongside the BQN?
 
1:12 PM
I am a non-commercial user/fan-boy pleased to be able to use your product for intellectual pleasure, so I don't really feel entitled to voice any 'demands'. I did raise a github issue. However, I'd assumed that if it can be made to work on linux, making it work on macos shouldn't be materially harder, posix and the same compiler tool chains and libraries available.
 
@MortenKromberg Original APL or modern/comparable APL?
E.g. ArrayLogic ← (>-<)⟜0 is (x>0)-(x<0) in the original, but a more comparable implementation would be ArrayLogic ← (>-<)∘0
 
RGS
@Adám so this is supposed to work for windows users as well?
 
@RGS I fully expect that in 19.0 you can have a single #! script that can run on all platforms.
 
RGS
@Adám well that I know; maybe I didn't follow the conversation but wasn't that (= the bash script you wrote) supposed to be a script one could use, which would cheat and execute an APL file more or less like a script?
uh too many instances of the word "script" in the sentence above; can you understand what I mean?
 
@RGS Sure, but it is very bash-specific. The DYALOG_LINEEDITOR_MODE=1 works on Windows too. If you have not enabled it, do so!
 
RGS
1:19 PM
@Adám the dyalog line editor thing is the experimental multi line? Have been trying it already
 
Yes, exactly. I can't live without it now.
 
RGS
btw it has a minor issue; if I do, say, function ← { and then hit return to start multi line, if I then change my mind and go back to writing the dfn in a single line, writing the final } doesn't terminate the multiline
 
Is that the bit where one can type in dfns as-is in the repl?
 
RGS
@RGS this isn't terrible, just mildly annoying
 
Yes, and scripts and control structures too.
@RGS Ooh, I'll add that to the list of issues. It is highly experimental atm.
 
1:21 PM
And it's not even my birthday!
 
RGS
@xpqz imagine if it were :D
@Adám yes I know, just trying to help out :)
 
Wot, hash tables??
 
@xpqz ?
 
@MortenKromberg Probably not. It's often hard to figure out what the "original APL" is, as many of the pages are discussions with much more code than is actually used to solve the problem. And as Adam notes, the originals use expressions rather than functions.
 
@Marshall But I think it'd be valuable to have the closest (reasonable) APL equivalent in the doc.
 
1:27 PM
@Adám jk - rattling off issues of my "most wanted" list. For my birthday.
 
@Adám I think the page is more valuable as a plain BQN resource than a comparison, despite the APL connection. In any case, I'm not really interested in writing APL code in any capacity any more. If you'd like to do your own comparison, feel free.
 
@xpqz this?
 
@MortenKromberg There is a Dyalog/BQN conversion table that may be helpful.
 
Yeah, I know how it is done -- I just occasionally wish for a k-style way that arrays could simply be indexed by a string 'directly'.
 
@xpqz You know about this, right?
 
1:39 PM
Yes -- name spaces and objects and using ⎕JSON goes some way, but the closest I've found is the dfns.dyalog.com/n_alists.htm stuff -- but it's just too inefficient for anything that's update heavy rather than read-heavy.
Or maybe I'm missing some trick.
 
RGS
(in the )ed window, is there a way for me to indent a block of lines? selecting them and pressing tab replaces the whole code with a tab :P )
 
@RGS cmd-]
 
RGS
@xpqz what is cmd on Windows?
 
(kudos to RIDE team - that's the same in any other IDE I've tried)
 
RGS
@xpqz btw I am not using RIDE
 
1:43 PM
Try control
 
RGS
@xpqz I did :P And ctrl+shift and altgr
 
@RGS I don't think there is. But you can auto-indent everything.
 
RGS
@Adám using the "edit > reformat"? that is going to mess up my whitespace
Also a shame that you can't perform a search&replace inside the selected text
 
@ngn (i should note that when it comes to actually testing things i much prefer just getting told if everything's correct, and if not, what went wrong, but when it comes to setting up a presentation of the code in a place where 99% of people won't know the language, seeing only "all tests passed" is extremely unhelpful)
 
@RGS Yeah, that's another missing feature. I'll ask John if we can have indent/outdent shortcuts and a replace-in-selection checkbox in the find/replace dialog.
 
RGS
1:53 PM
@Adám +← 1
 
ngn
@xpqz credit should go to codemirror
 
ngn
2:13 PM
@dzaima so, your point is that for an unfamiliar language you'd prefer to see the outputs? but there's no reason why "all tests passed" should be skipped, right? otherwise it would be hard to play with the solution - you wouldn't know at a glance if you've broken something or not.
 
RGS
@Adám (did you manage to solve this?)
 
@RGS Yes, that should be fixed in APLcart now and in the upcoming re-build of 18.0.
 
RGS
@Adám +← 1
 
@ngn i think it'd be more confusing to try to test a specific input if you also had to worry about providing a corresponding output. In viewing other answers, i very highly value being able to extremely easily edit the input (compared to the "edit input field" for many other answers, having a test-case setup, potentially with extremely long lines due to having to include 1Dified 2D ascii-art, is pretty annoying)
 
ngn
@dzaima just provide 0 as expected output. a failing test should print (in;expectedOut;actualOut)
 
2:25 PM
@ngn what if i mix up input and expected output?
(having to try an average of 1.5 times is still worse than "edit input field")
 
ngn
@dzaima why would you do that?
 
@ngn if the input and output are of similar form (e.g. slightly modify ascii-art, one confusing long number to another confusing long number); i as the answerer would know, but others may not as easily (especially so with 1Dified ascii-art)
 
ngn
@dzaima that rarely happens. if solving with a challenge like that, i'd put a comment like /t[in;expected] before my tests, so it's clear what the args are
but even that is not necessary, as the tester function itself hints about what is what, even if you don't speak the language
 
@ngn and then someone asks "what does [in;expected] do in this funky language? Also how do i test this? :p
 
ngn
i would answer :)
btw, sometimes when i look at other people's golfs (if written in "all passed" style), i try changing something in the tests, just to make sure they would fail
 
2:34 PM
@ngn i do that too. Wouldn't have to if they just gave outputs for inputs
 
ngn
@dzaima but then you wouldn't know if they pass at all
ignorance is bliss but..
(you would know, but it takes a lot more effort)
 
@ngn in many cases it's reasonable easy to see whether an answer is correct (compare with the question's results, just using logic)
(especially if you're testing the answer in conjunction with testing all other answers, i.e. testing some edge case)
@ngn you also have to trust that the test-cases are actually correct, it's not unreasonable for one to mistakenly write a 0 instead of 1, or copy their own result into the test-case instead of the official result
 
ngn
@dzaima yeah, that could happen
 
(seeing a wrong 0 or 1 would be easy, seeing something wrong in a 1Dified ascii-art is not)
@ngn and that makes an answer pretty much immune, as testing more things is non-completely-trivial, i.e. not worth bothering, and noone would bother to see if the test-cases are correct
 
ngn
@dzaima but if you write your tests as t[in;expected] (k) or in t expected (apl), you already have that information to look at
 
2:43 PM
@ngn right, but again, 2D ascii-art
 
ngn
@dzaima i don't understand. what's wrong with 2d?
if your input is 2d, do a←⊂.. ⋄ a,←⊂.. ⋄ .. ⋄ a←↑a on separate lines
and it will look fine
 
@ngn with more than ~3 pairs of those in the test suite it just starts to be a lot of taken up space. i personally would just go with a single line (if testing more than one input, which i often don't, and just have the whole input as the input)
 
ngn
@dzaima taken up space - that's why multi-line matrix syntax matters. go, @Adám!
 
@ngn On it, on it. In fact the project is progressing faster than expected.
 
(also the input space in canvas is pretty small, focused on output a lot more, scrolling trough both inputs and outputs in it might be too much to bother, and it'd be understandable to either do nothing or just delete it all and try to input your own input)
 
ngn
2:50 PM
@dzaima there are other tricks too, like read from stdin (←⍞) until () empty line, and mix
 
@ngn what if i want to give an n-line empty input?
 
ngn
@dzaima then make it read until a line that contains only a '.' :)
it's a question of the relative importance of knowing instantly that tests passed.
for me it's very important not to break flow
 
@ngn right, my point being most people wouldn't bother asking if they can't figure out how to properly test (some might not even try, guessing that your testing framework would just output fail on failed tests, instead of giving the output by some garbage they decided to leave behind)
(when it makes sense (i.e. output isn't ascii-art) i do often have testing locally, but still don't put it in the answer)
and when the output is booleans/some other limited amount of things, i group inputs by their output, with some separator
 
ngn
@dzaima grouped boolean - yes, that works too. i can tell if it's ok without thinking much.
 
3:11 PM
@ngn as we talked about this above; this is my 2017/24 solution: gist.github.com/xpqz/281587aaa9618331396b73da3695f49b -- depth-first recursive descent. It's passably quick (~5s) despite the non-tail-recursive approach, but any dfn approach I could think of just became hideous. So was wondering - is there a more "array" way of formulating this?
 
ngn
@xpqz i've forgotten.. i'll read the problem again
 
It's dominoes, basically
Lay out a chain of dominoes to maximise the total sum of "dots"
 
ngn
3:34 PM
@xpqz 5s sounds very slow for this problem. have you tried solving it somehow with dynamic programming?
 
My solution is basically "enumerate all possibilities starting from 0, keeping track of the largest sum". So: brute force, no smarts. But I did spend a fair bit of thinking and couldn't see a better algorithm.
 
ngn
@xpqz how about this: a[i] is the strength of the strongest bridge that ends with an i connector
we initialise a with infinities, except for a[0]=0
then we add the "dominoes" one by one
i'm too distracted now.. i'll give it a try later
 
4:00 PM
@nope Welcome to the room. Interested in APL?
 
RGS
4:54 PM
@Adám I guess the name answers the question? How do all these people end up here..?
 
Maybe looking for a chat, and our room is among the most active on SE.
 
RGS
@Adám the whole network?
 
5:15 PM
@RGS Yeah.
 
6:01 PM
hello (oh by the way this is still @matt)
 
6:58 PM
for this code for integer division, Java 8 & 11 give 0.0031ms for 1000 item arrays, whereas java 14 takes 0.0062ms ಠ_ಠ
(couldn't get it to give me the assembly its generating, but the pretty much only thing it could be doing is not merging division and modulo)
 
 
1 hour later…
ngn
8:11 PM
@ngn @xpqz what nonsense did i write there.. this is hamiltonian path in a multigraph, it's likely np-complete
("likely" because edge weights have a special property - they are the sum of the labels of the two vertices they connect; i don't see a way for this to be exploited)
 
 
2 hours later…
ngn
9:42 PM
e←⍎¨'/'⎕r','¨⊃⎕nget'24.txt'1
s←+/↑e⋄n←1+⌈/∊e⋄g←(⍳n)∘.∊e⋄u←∘.≠⍨⍳≢e
0{∨/c←⍵∧⍺⌷g:⌈/t+(-⍺-t←c/s)∇¨↓⍵∧⍤1⊢c⌿u⋄0}≡¨e
@xpqz ^this runs in <1.5s on my laptop
 

« first day (1267 days earlier)      last day (337 days later) »