« first day (1118 days earlier)      last day (1537 days later) » 

12:37 AM
Is there a way to make a regex replacment only replace one instance rather than all instances?
 
12:55 AM
@JoKing Yes:
⍞←'ss'⎕R'XX'⍠'ML' 1⊢'mississippi'
 
@Adám miXXissippi
 
ML for Match Limit.
 
great! Are these options documented somewhere?
btw, I was solving the 2019 Dyalog problems, and the IP one in phase 2 seems rather underspecified
 
@JoKing Have you looked at the documentation for ⎕R? You can always hit [F1] or type ]help ⎕R, even with the bot.
 
1:47 AM
Finally got a working APL solution to this challenge, though the code is really ugly because it involves lots of "run this piece of code based on which of the conditions is true" constructs.
 
2:16 AM
 
 
5 hours later…
7:44 AM
@user48534 Hi John Foley, if you want to participate in this room, just email me: adam@ with the same domain as www.dyalog.com
 
 
3 hours later…
11:13 AM
@Adám ahh, I definitely looked at that page but managed to miss that entirely, oops.
 
 
2 hours later…
1:34 PM
@Adám Why is it that when I run this code on TIO, I dont get any output?
Output should be 25
 
@JPeroutek Header, Code, and Footer need ⎕← to output. Try it online! Moving the actual execution to "Input" obviates this. Try it online!
Look at Header, Code, Footer as declaring your workspace, and Input as what you'd type into the session (the interactive REPL).
 
Ahh that makes sense. I think I'm ready to submit my first APL answer!
 
@JPeroutek Nice. If what you linked is the code you're about to submit, I can give you some golfing advice should you want.
 
I'm going to give golfing it a shot after I finish the test cases. I can see a few spots that need editing
 
@JPeroutek Also, you can get the code length counter to not count f← by removing f← from Code and instead putting f←⍎⎕IO⊃¯3↑⎕SRC⎕THIS (yes, I know, pure magic) into Footer.
 
1:41 PM
Ahh, thanks. I definitely would not have gotten that one
 
@JPeroutek If you ever forget the magic incantation, the bot can help:
f←{((⍵|⍺),⍵){+/⌈/⍵×1=(¯1↑⍺)|⍵×⊃⍺}⍳⍵}
 
@JPeroutek Some of these are really helpful:
29
Q: Tips for golfing in APL

gthacoderI started one code golf challenge recently and it seems like the winner is GolfScript (surprise, surprise!). What's interesting is that there was another very strong competitor that had all chances to win over GolfScript. Its name is APL. I see a lot of answers written in APL here. It seems like ...

E.g. (⍵|⍺),⍵ is the "Use " tip "Avoid parentheses" giving ⍵,⍨⍵|⍺
 
I probably did this in the worst way possible, but essentially the inner function needed 3 arguments, so I paired up the original two and passed in iw in place of the original w
So the order of (w|a , w) can probably be changed
 
1:53 PM
Also, ¯1↑⍺ can become ⊢/⍺ or ⊃⌽⍺
@JPeroutek Actually, you don't need the comma then as (⍵|⍺)⍵ works too.
 
@Bubbler yay for apl answers to unanswered challenges, but i'm surprised the apl/python bytecount ratio is so high
 
@JPeroutek I see that, but it is much shorter to give ⍳⍵ a name: Try it online!
 
@Adám Wow, that is significantly shorter
0
A: Modular multiplicative inverse

JPeroutekAPL (Dyalog Unicode), 38 bytes {+/⌈/i×1=⍵|(i←⍳⍵)×⍵|⍺} Try it online! Much thanks to Adam in the APL Orchard chatroom for the help with this one!. First iteration: {((⍵|⍺),⍵){+/⌈/⍵×1=(¯1↑⍺)|⍵×⊃⍺}⍳⍵}

 
@JPeroutek You can actually get it a little shorter than that by using tacit programming, but it requires learning some new techniques: Try it online!
 
Not going to lie, I have no idea what that code is doing.
Is that technique covered in the Mastering Dyalog APL book?
 
2:03 PM
@JPeroutek what is the purpose of the +/ in the front?
 
In the code he just posted?
Sum over
I think?
 
Huh, but there's nothing to sum, just a single number.
 
conjugate?
 
btw, did you note the "The program should finish at some point, and should solve each test case in less than 60 seconds" restriction?
 
@JPeroutek It doesn't seem to do anything in this case.
@KritixiLithos When I golf other people's codes, I tend to just apply experience rather than understanding ¯\_(⍨)_/¯
@JPeroutek Oh hey, since this is your first APL answer, and the first APL answer on that challenge, you can sign up for a +100 rep bounty here, and if you explain your code too, then you're entitled to +200 rep.
 
2:06 PM
@KritixiLithos The TIO instance seems to have restrictions on Workspace size.
iota of a big number gives a debug message
Is there a recommended method or format for explaining APL code? Ive seen others' explanations, should i just copy their format?
 
@JPeroutek Not really. Some people write dissertations, some explain pieces, some put comments in a spaced out code block. I make indented explanations.
 
@JPeroutek i can't test it locally, increasing the maxws to 2G is not enough
 
Really?
Hmm. I probably did something wrong. I don't know.
 
73714876143 is a big number
 
@KritixiLithos @JPeroutek Let's see, 73714876143 would need that many 64-bit floats…
… about 550 GB. That's a reasonably large amount of RAM.
 
2:16 PM
So the solution is to turn my entire drive into swap space
 
How would I curry a dyadic function, say {⍺+⍵} to create a monadic function that adds 5 when applied mondadically? There is a section Right Operand Currying in the language reference, but can't quite wrap my head around that.
 
@JPeroutek Unless you have a very fast drive, I doubt you can write half a terabyte in 60 seconds.
@xpqz 5∘{⍺+⍵} or {⍺+⍵}∘5
 
0
A: Modular multiplicative inverse

JPeroutekAPL (Dyalog Unicode), 38 bytes {+/⌈/i×1=⍵|(i←⍳⍵)×⍵|⍺} Try it online! Explanation: ⍵|⍺} ⍝ Get ⍺ mod ⍵ (i←⍳⍵)× ⍝ Multiply the result by all numbers up to ⍵ ⍵| ⍝ Take result mod ⍵ i×1= ⍝ Find all numbers (1,⍵) wher...

Is this a suitable explanation
 
@JPeroutek It is.
 
@Adám so neat, once you know how. Many thanks.
 
2:40 PM
@JPeroutek If you want me to, I can explain it.
#tio alias command f← #tio apl do ⎕←'https://tio.run/##','\+' '='⎕R'@' ''base64 10↓¯8↓256|⊃⌽3(219⌶)¯128+256|128+∊{255,⍨'UTF-8'⎕UCS⍵}¨'apl-dyalog' ''(170↓2⊃⎕SRC⎕THIS)'f←⍎⊃⍬⍴¯3↑⎕SRC⎕THIS'⊣'base64'⎕CY'dfns'⍝%args%
 
@Adám Added alias for f←
 
f←{'test'}
#tio alias command f← #tio apl ⎕←'https://tio.run/##','\+' '='⎕R'@' ''base64 10↓¯8↓256|⊃⌽3(219⌶)¯128+256|128+∊{255,⍨'UTF-8'⎕UCS⍵}¨'apl-dyalog' ''(170↓2⊃⎕SRC⎕THIS)'f←⍎⊃⍬⍴¯3↑⎕SRC⎕THIS'⊣'base64'⎕CY'dfns'⍝{'test'}
 
@Adám Added alias for f←
 
f←{'test'}
 
 
1 hour later…
4:00 PM
Small progress; used complex numbers to represent x,y coordinates. :)
Are the forms which come from ⎕WC 'Form' .Net WinForms, or are they a Dyalog implementation which predates that? I was hoping to find a way to SetPixel() on them, but can only ⎕WC 'Circle' and then end up with tons of circles
 
@TessellatingHeckler They are WinForms in a Dyalog namespace wrapper.
 
@Adám ok. I can probably figure out an Image or Bitmap from that
 
@TessellatingHeckler There's a bitmap object.
 
4:23 PM
@Adám I had seen that; it doesn't look like a System.Drawing.Bitmap - docs.microsoft.com/en-us/dotnet/api/…
 
@TessellatingHeckler No, but you should be able to make one of those with ⎕USING.
 
drawing.Bitmap has lots of methods, including GetPixel and SetPixel
@Adám fair enough
 
@TessellatingHeckler ⎕using←',System.Drawing.dll' ',System.Drawing.Common.dll' ⋄ ⎕new System.Drawing.Bitmap …
 
Given a character vector of the type 'X1234', to return a length two vector of the letter and the number, I came up with {a←1↑⍵⋄b←⍎1↓⍵⋄a,b}'X1234' -- is there a more idiomatic way?
 
@xpqz (If you stick **CMC:** in front of such requests, you launch a Chat Mini code golf Challenge!)
@xpqz Do you know that the input is one letter followed by 4 digits?
 
4:30 PM
@xpqz I'd guess that the left shoe mashup of functions will be involved
 
Single letter, at least one digit, but could be more or fewer than 4
 
@xpqz I'd do 1(↑,∘⍎↓)'X1234'
 
A long train!
Cool.
 
I'd say a relatively short train. 3 carriages.
 
I really like that solution @Adám
Nice and neat
 
4:33 PM
I wish I could have thought of that...
 
Of course, using on unfiltered user input would be dangerous. (⊃,∘⍎∩∘⎕D)'X4234' is safer, but can throw an error.
1(↑,2⊃∘⎕VFI↓)'X1234' would be the industrial strength version.
1(↑,1↑2⊃∘⎕VFI↓)'X1234' will give you exactly one number, no matter what, and will fall back to 0 if none is given.
 
I need to study that for a while to understand what it means...
 
@xpqz Does this help:
⎕←(↑,1↑2⊃∘⎕VFI↓)
 
@Adám
┌─┼───┐
↑ , ┌─┼───┐
    1 ↑ ┌─┼─┐
        2 ∘ ↓
         ┌┴┐
         ⊃ ⎕VFI
 
That shows the train execution order?
 
4:42 PM
@xpqz No, it shows the bindings.
@xpqz It wasn't far from you:
{a←1↑⍵⋄b←⍎1↓⍵⋄a,b}'X1234'
{(1↑⍵),(⍎1↓⍵)}'X1234'  ⍝ substitute variables
1{(⍺↑⍵),(⍎⍺↓⍵)}'X1234' ⍝ break out 1
1((⊣↑⊢),(⍎⊣↓⊢))'X1234' ⍝ train
1((↑),(⍎↓))'X1234'     ⍝ simplify
1(↑,∘⍎↓)'X1234'        ⍝ remove parens
 
With your last example (the industrial strength version) -- I get an error, what am I doing wrong? INDEX ERROR
1(↑,1↑2⊃∘⎕VFI↓)'X1234'
 
@xpqz Do you have ⎕IO←0 ?
 
Ah yes
 
Then you need 1⊃ instead :-)
 
Sorry for total n00b questions...
 
4:52 PM
Not at all. Any time (almost). And regarding ⎕IO — we've all been (and continue to get) bitten by that one.
 
Is there a consensus on ⎕IO? Or pick one and stick with it?
 
@xpqz Yes, the vast majority agrees that having a single fixed value would be better than giving the choice. Always localise/set/declare ⎕IO for production code.
 
As a personal observation I'm saddened I didn't discover APL earlier. So much fun.
@Adám when you showed the bindings above, what does that mean?
 
@xpqz You can See that and ⎕VFI are bound as operands to and that forms the middle tine in the 2 g ↓ fork, and that forms the right tine in the 1 ↑ h form, and that forms the right tine in the ↑ , h fork.
CMC: Beat this.
 
 
3 hours later…
8:30 PM
@Adám {⎕←⌊⎕DL⍵}&¨⎕ as long as the delay is slightly longer than requested, although I assume there's a chance it might be under and then will return incorrect results.
⌊∘⎕DL&¨⎕ even
 
@TessellatingHeckler Getting there. :-) One more byte by answering with a function, i.e. dropping
 
@Adám ⌊∘⎕DL&¨ ?
 
Yes.
 
@Adám :D Is it .. valid to assume ⎕DL will be over the time, and never under it? (⌊.5+⎕DL)&¨ from the APLCart "round to nearest whole number" is also shorter, but not as short
 
@TessellatingHeckler Dyalog and IBM do not seem to guarantee it, but APLX does guarantee it. I think it has to be "at least" according to the ISO spec. I've just run a few thousand trials of 0.1 and 0.01 secs and none were faster.
I guess I could look at the source code to see how it actually works.
 
8:43 PM
@Adám I ran three trials, and that was good enough for me
(But I was predicting you'd pick up on it)
 
I think that especially when there's a thread-switching overhead, there's no risk of it being under.
Ran a thousand trials on APL2. None were too fast there either.
 
8:55 PM
@TessellatingHeckler Right, ISO/IEC 13751:2001 says "Wait until current-time is not less-than T1."
Then again, it also says that the requested time may be fractional or negative, so I guess we should take that with a grain of salt. Neither Dyalog, APL2, nor APLX allows negatives.
⎕DL ¯3600 would solve a lot of the worlds problems if it worked…
 
9:18 PM
@Adám I have enough trouble with acceleration measured in seconds squared.
but I can only think that "not delaying an hour" would mean skipping forwards over an hour, rather than backwards, and not being too helpful
 
@TessellatingHeckler It isn't "not delaying", it clearly means "roll the state of the universe back one hour".
 
9:33 PM
@Adám if a delay is shifting the universe state 3600 seconds ahead while the program state stays still, then changing the sign might shift the program state 3600 seconds ahead while the universe stays still, doing an hour of computation in no time. Whether that's identical to shifting the program back in time an hour, so it can-have-done an hour of computation by now.. or rolling back the Universe ..
hm; rolling the universe state back would affect the program, because the program is part of the universe. That would roll back an hour in state, progress in exactly the same way up to the delay, then that would be an infinite loop
anyway, E. Yudkowsky says time doesn't exist, and I should probably take his word for it
 
@TessellatingHeckler You're making it too complicated. It is really simple. ⌈∘⎕DL&¯3600 will simply print ¯3600 an hour before you enter the expression into the session. \○/
 
10:12 PM
@Adám Sounds a lot like Asimov's crystals which are so soluble they dissolve 1.12 seconds before they contact water
 

« first day (1118 days earlier)      last day (1537 days later) »