« first day (408 days earlier)      last day (2232 days later) » 

1:00 PM
@EriktheOutgolfer Here is a wrapper that allows you to assign a one-liner dfn or tacit fn to f without counting f←.
 
@Adám hm, that looks useful, thanks
@Adám wait, would f be global?
 
@EriktheOutgolfer Yes; it is a tradfn.
 
1:16 PM
@Adám holy moley. I had to leave early yesterday and only got to see this now
Thanks a bunch, I'll check it out
 
@J.Sallé Notice that it is your exact program, except using indexing instead of the inner :Ifs and collapsing :For-loops to {_ while giving a left argument to replace the global.
@J.Sallé Of course, one should never write like this in production code. Yours was perfectly good and legible.
 
@Adám hahahahah I'll keep that in mind. I'm trying to use it on the simplest case '>' but it throws a value error on the last ⍳⍺, do I need to call it with parens?
 
@J.Sallé Yes, it is a train. Also remember ⎕IO←0 as before.
 
@J.Sallé It needs a character vector (not scalar) as argument.
 
1:34 PM
@Adám like so?
 
@J.Sallé Yes. If that result format isn't acceptable, stick a on the far left.
 
@Adám will do.
 
2:29 PM
@J.Sallé Here it is "ungolfed". I'm sure you can explain it like this:
⊂{
      i←⊃t←⍬⍳⍺
      t/⍵⊣⍵{
          i+←¯1 1 0⊃⍨'<>'⍳⍵
          e←t[m←⍺|i]
          t[m]←('01!'⍳⍵)⊃0 1,e,⍨~e
      }¨⍺
  }¨1+⍳∘≢
@J.Sallé Actually, if you want, you can change i⊢←i+ into i⊣i+← for the same byte count but easier to explain and ungolfed. This is what I used in above "ungolfed" version.
 
@Zacharý I would consider this one pretty Adám'd, wouldn't you? — J. Sallé 50 mins ago
then maybe you haven't seen ngn'd code
 
@EriktheOutgolfer But he's right, I just golfed his code with not understanding of what it was supposed to do. ngn would use a (cumulative) reduction like you did.
 
@Adám uh, what did I do?
I sincerely hope I didn't sleep-edit somebody else's answer
 
@EriktheOutgolfer {⍎∊'0@1' '1@1' '~@1' '1⌽' '¯1⌽'['01!<'⍳⍺],'⊢,',⍕⍵}/
 
@Adám ah, nice! I'll edit it in
 
2:44 PM
@Adám oh haha if it was cumulative it would've been impractical
 
@EriktheOutgolfer that was a reference to this message actually hahahahah
 
The agenda is now available for SwedAPL '18 on the 4th April in Malmö. It is free to attend but places are limited - see here for details and to register http://swedapl.se/#home
 
@Adám What is i←⊃t←⍬⍳⍺ doing exactly? Is that a dyadic ?
 
1
A: Tips for golfing in APL

AdámConstant functions =⍨ and ≠⍨ thanks to ngn. Sometimes you just need a single value for each element of a list. While you might be tempted to use {value}¨, it is shorter to use value⊣¨ but for some common values, you can get even shorter (using ⎕IO←0): ¯1s with ⍬⍸list 0s with ⍬⍳list 1s with ⍬...

@J.Sallé It finds the locations of each element of in , but since there are no elements in , each becomes the first index beyond the end, i.e. 0 in ⎕IO←0. So it makes one zero for each element in , and since that's all zeros of course, we can take the first one and use for i.
 
@Adám ah, I see. That's clever, I don't think I've seen that before
@Adám and then the t/⍵⊣⍵ replicates the vector of 0's in t to and uses that as for the nested function?
 
3:03 PM
@J.Sallé No, notice the . It is which becomes the left argument, but the result isn't needed, so we discard it in favour of using . Then t, which is the final memory state is used to compress (the length), because if there are is a 1 in the final memory state, it will give ,⍵, while if there are none, it gives .
 
@Adám ah, I see. I'm also having trouble with explaining i+←¯1 1 0⊃⍨'<>'⍳⍵. I think it's 'mapping' (perhaps not the best word, but anyways) '<>' in , but where does the 0 comes from?
If it's anything other than '<>', it becomes a 0?
 
@J.Sallé Yes, remember that dyadic will give an index one higher than the last index if the sought element isn't found. That's exactly the same principle as used with ⍬⍳.
@J.Sallé Remember that all functions are right-associative, so the dfn can only "catch" while the must use the dfn's result as its right argument.
 
@Adám yeah, I think I got that.
I'll finish the edits later, need to go get some lunch now :p brb
 
 
2 hours later…
5:15 PM
@J.Sallé "And do that n times, where n is the length of the input." → "And do that for each possible tape length from 1 to the length of the input."
 
@Adám sounds good, gonna change it. Thanks :)
 
 
6 hours later…
11:28 PM
@J.Sallé Nice stuff, I had (4∨?2)⌽(⌽,1∘↓)3?10
 

« first day (408 days earlier)      last day (2232 days later) »