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.
@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.
I 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 ...
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
APL (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 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.
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.
APL (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...
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
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 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.
@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.
@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.
@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.
@TessellatingHeckler Right, ISO/IEC 13751:2001 says "Wait until current-time is not less-thanT1."
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…
@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. \○/