« first day (355 days earlier)      last day (2309 days later) » 

12:20 PM
@Adám yeah, and it's nice to see people basically creating an account just to answer that hahahahah
Also couldn't apply for that license yesterday because I'm still without internet connection at home D:
 
@J.Sallé Can't you send emails?
 
@Adám my phone doesn't have a 3g connection anymore, so no :p
I'll apply now though hahah
 
@J.Sallé OK. Karen is at her desk, so it should go quick.
 
@Adám Done :)
By the way, I was talking to a friend about APL the other day and she asked me a question that made me realize something: I've no idea what APL is used for commercially speaking. What kinds of applications people usually code in APL?
 
@J.Sallé Good question. Some examples.
 
12:34 PM
Oooooooh that page is great!
 
12:55 PM
@Adám if I'm indexing something with a , can I get multiple indexes at a time? 1 2⌷vec doesn't work (obviously because it's not a matrix); I think I'll have to mix some s and ¨s. I tried ⌷vec⍨¨(1 2) but it also didn't work.
 
Ven
@J.Sallé you need to (⊂1 2)
 
@Ven aaaah I see. Thanks a lot!
 
1:10 PM
@J.Sallé As Ven said, or use 1 2⊃¨⊂vec (known as the chipmunk)
 
@Adám elegant, hahahahah
@Adám also, if I chain multiple guards, the order of the diamonds will be reversed? Like so: {guard1:guard2:guard3:⋄else3⋄else2⋄else1}?
 
@J.Sallé You can't chain guards like that (yet). If the tests are independent, you can just use {guard1:val1 ⋄ guard2:val2 ⋄ guard3:val3 ⋄ else}
@J.Sallé (And if we do introduce them, then they will be "AndIf"s, i.e. {If1:AndIf2:AndIf3:Then⋄Else})
 
@Adám I see. If they're not independent I should nest functions, then? {guard1:{cond2:{...}⋄else}⋄else}?
 
@J.Sallé Yes, unfortunately, until further notice. However, if you can make all the the tests and have a single "then" and a single "else", you can do {guard1∧guard2∧…:then ⋄ else}. If you have an entire binary tree, you may be able to select the result using 2⊥ as in None One Two OneAndTwo Three[⎕IO+2⊥Guard3 Guard2 Guard1]
@J.Sallé Generally, if I have a lot of decisions in my algorithm, I go with a tradfn to get proper structured programming.
 
1:26 PM
@Adám Yeah I think I'll have to resort to that. I'm trying to solve this, and the approach I'm using is to eliminate as many iterations as possible.
So I'll only have to iterate through a few numbers instead of them all.
If I use pco inside a tradfn do I need to copy it inside the function or just the usual ⎕CY 'dfns' in the session?
 
@J.Sallé Either way. AFAICT, it will count as the same number of bytes.
 
Okay, I'll try that
 
 
1 hour later…
2:34 PM
@Adám I tried a little golf on part of my function but it's erroring:
    :If ∧/(m d=2 29)
     :AndIf ~(400|⍎((≢n)-4)↑n)
Should I just do :AndIf (400|⍎((≢n)-4)↑n)=0 instead?
Oh nevermind, I just noticed how stupid that is.
 
@J.Sallé In any case, you can do :If m d≡2 9 instead of :If ∧/(m d=2 29)
 
Is there a fast way to clear the stack (⎕SI)? I've been holding ESC but current stack has >1600 entries
@Adám I'll try that
)RESET works for my question
 
@J.Sallé )SIC is Stack Indicator Clear. Same as )reset.
 
@Adám okay good.
r←f x
 ⎕CY'dfns'
 n←⍕x
 :If x=⌽x
 :AndIf 1 pco x
 :AndIf (m←(⍎¯2↓¯4↑n))<13
 :AndIf (d←(⍎¯2↑n))<32
     :If m d≡2 29
     :AndIf (400|⍎((≢n)-4)↑n)=0
         ⎕←x
         f x+72
     :End
     ⎕←x
 :End
 f x+1
Can you tell me why is this printing non-palindromes?
 
@J.Sallé What is an example argument?
 
2:45 PM
@Adám 10000101
f 10000101 prints the following:
 
Ven
I think Dyalog APL is the only language I know that has a "AndIf"
 
10000103
10000121
10000223
10000229
10000303
10000511
10000609
10000721
10000723
10000813
10000819
10000831
10000931
10001009
10001107
10001119
10001203
10001207
10001209
10001213
 
@Ven The only, you mean?
 
None of these are palindromes D:
 
Ven
@J.Sallé x=⌽x is not scalar. you want ∧/x=⌽x
 
2:47 PM
@Ven oooooooooooooooooooh that's right
I could just use though right?
 
@J.Sallé Yes.
 
Ven
yes
 
Seems to be working now, although it won't print anything before timing out in TIO
 
@Ven In regular languages if (a&&b) is enough. Simple conditional functions/ops are a thing I miss in APL
 
Ven
@dzaima well, a&&b is easy enough. for more complex cases you can always chain or AND-reduce
 
2:55 PM
@dzaima You do have :If a ∧ b, but what if you don't want to do the b test if a is enough to determine that this If won't execute?
@dzaima What's wrong with f⍣condition ?
 
Ven
@Adám most languages do shortcircuit...
probably was @dzaima's point
 
@Ven mhm. There have been times when I just nest dfns to do that
 
@Ven Ah, I see, but that's just so inconsistent. What if b has a side-effect what you want?
 
Ven
@Adám then you use the bitwise versions, & and |.
 
@Ven Wait, so && in dzaima's example is not a simple Boolean operation?
 
Ven
2:58 PM
@Adám it is. it deals with booleans, not bits.
 
@Ven But that's the same in APL.
 
Ven
@Adám APL doesn't short-circuit, so no
 
@Ven I suppose all this only applies if a and b are pre-calculated, not function calls?
 
Ven
@Adám I assumed a and b to be arbitrary expressions and not variables.
 
@Ven So expr1&&expr2 will never execute expr2 if expr1 evaluates to false, while expr1&expr2 will always execute expr2?
 
Ven
3:01 PM
@Adám correct.
 
@Adám I'll agree that there is inconsistency, but, as long as the default is to not use the short-circuiting (i.e. & is quicker to type than &&), those who need it, would rather remember arbitrary rules rather than do obscure & longer things.
 
@Ven @dzaima Yes, that would be valuable. There is a proposal to allow {a:b:Result if both true} which would solve this problem.
 
This is more of a meta question, I guess, but anyway: Can I post a solution to a challenge with a shorter yet less optimized code, and post a more optimized code in TIO? (I'd explain it on the post body, naturally.)
 
Ven
@Adám how do you get OR-short-circuiting then? :P
@J.Sallé optimized perf-wise?
 
@J.Sallé I'd include both golfed and ungolfed version in the post.
 
3:07 PM
@Ven yes. I literally just added a couple ifs that cut the number of iterations down by ~60% but that are not strictly necessary.
@Adám yes, I thought of that too
 
@Ven It wouldn't solve that. Maybe not high priority for the functional programming focused dfns. Tradfns do have short-circuiting :AndIf and :OrIf etc.
 
Ven
Well, it depends. Haskell i.e. doesn't have this issue by virtue of being lazy.
 
@J.Sallé That's my suggestion as well - link to normal, and then after that a link to the optimized code
 
@dzaima sounds good.
 
@Ven Haskell is functional, so it's really not comparable to APL
 
Ven
3:09 PM
@dzaima I was replying to :42292284
 
@Adám I always forget: we count the s towards the byte count, right?
 
@J.Sallé Not in a tradfn. Don't even count the header line if you don't use it.
 
Ven
@J.Sallé The answers you got on SO are all so amazing :o.
APL is so history-rich.
 
@Adám nice, then I'm at 156 bytes
@Ven yeah, the one I accepted is so great
And as I said, a dude actually created an account (or used an inactive one) to answer.
 
Ven
"Member for 8 days" wow!
 
3:17 PM
@Ven You can get short-circuiting OR←{⍺⍺⍬:1 ⋄ ⍵⍵⍬} with the usage var←3 ⋄ :If {var=42} OR {⍵∊⍳3⊣⎕DL 1⊣'expensive test'}⍬
 
Ven
@Adám Yes, I know, I meant more like ||'s short-circuiting.
 
@Ven Yes, I will begin to encourage posting APL Qs on SO instead of/complementing in here.
 
Ven
I still havn't asked a single question on SO, actually..:-) maybe an APL one will be my first
 
@Ven How does that work? Not like the &&?
 
Ven
@Adám a||b short-circuits if a is true, just like a&&b short-circuits if a is false.
 
3:20 PM
@Ven Right. That's What OR←{⍺⍺⍬:1 ⋄ ⍵⍵⍬} and AND←{⍺⍺⍬:⍵⍵⍬ ⋄ 0} do.
 
Ven
3:32 PM
oh, Morten has a SO account
 
@Ven Sure. A lot of us do. He even joins this room and the APL lessons sometimes.
 
Ven
I need to browse the APL tag more often. It's great.
 
3:57 PM
@J.Sallé {9≤10⍟⍵:⍬⋄0::∇1+⍵⋄∇1+⎕←⍵⊣÷(2⎕NQ#'DateToIDN',⍎¨(2⊥⍣¯1⊢266)⊂⍕⍵)(1 pco ⍵)((⊢≡⌽)⍕⍵)}1E8 is slow but does the job.
 
4:19 PM
 
@Adám that's got a lot of stuff I don't even recognize hahahah
Also, it seems to miss the first prime of the "test case" which is 100111001
 
@J.Sallé That's because I forgot to set ⎕IO←0 when I copied to TIO. Try it online!
@J.Sallé I don't think it uses much you don't know. Only 2⎕NQ#'DateToIDN' which converts from a serial number to a date.
 
@Adám ah, I see. You mentioned it's slow but it performs so much better than my tradfn though hahahah
@Adám I've also never used the log operator although I know it
 
@J.Sallé Well, this last one only checks actual dates.
 
@Adám I looked at the documentation for date/time related dfns but couldn't find any that would actually help me
 
4:31 PM
@J.Sallé n⍟m is just logₙ(m)
 
@Adám yeah, I know. I was just slightly confused as to why the hell was that star circled before I realized it was an operator :p
 
@J.Sallé Well, a function ;-)
@J.Sallé What do you need? First I thought of using DateToIDN to check for valid dates, but then I realised I might as well generate the entire range using IDNToDate.
 
@Adám yeah that too hahahahah. I think my screen resolution also doesn't help much since the symbol on my session is like this: prntscr.com/i0si7k
 
@J.Sallé Yeah, that is pretty bad if you don't know what to look for.
 
@Adám I was looking for something that worked like java's Date object to check if a date was valid or not
 
4:35 PM
@J.Sallé ValidDate←{11::0 ⋄ 1⊣2⎕NQ#'DateToIDN'⍵}
 
@Adám Another thing that kinda confused me was the double guard, I think I've never seen that before.
Also, functions are not in the Dfns documentation page (naturally) so I didn't find that ⎕NQ
 
@J.Sallé That's an error guard. Execution resumes after the e:: if an error of type e (although 0 means all) happens later.
 
@Adám So if an error of type 11 happens, execution resumes at 0⋄?
 
Even system functions' documentation wouldn't have helped you with that. ⎕NQ#'service' is a special way (not unlike ) to get certain services.
@J.Sallé Well, it just returns 0.
 
@Adám yeah yeah, I imagined so.
@Adám so that's a HAX!!1! hahahahah
 
4:43 PM
@J.Sallé Documentation. Good luck! ;-)
 
@Adám Hahahahahah yeah that's fair
 
@J.Sallé Date validator: {∧/(1↓⍵)≤12,28+⍵[2]⊃(≠/0=400 100 4|⊃⍵)@2⊢12⍴7⍴3 2}
 
@Adám that works for every date in the format of the challenge I assume?
 
@J.Sallé Yes.
 
5:04 PM
Nice!
 
 
6 hours later…
11:25 PM
@Adám reference implementation in Python?!
 

« first day (355 days earlier)      last day (2309 days later) »