« first day (1969 days earlier)      last day (688 days later) » 

10:11 AM
The beginnings of an implementation of Relational Algebra in APL: github.com/romilly/raapl
 
@RomillyCocking Use can be even easier: Start APL (e.g. via RIDE) with the configuration parameter LOAD=…/src/apl
 
Thanks
 
Btw, if the user does that, then Dyalog will call the function #.Run if it exists. You can use that as a replacement for good ol' ⎕LX
@RomillyCocking Consider adding a license.
 
10:28 AM
Oops - yes. It started a s a private project, and I forgot to add one.
Now all three of your suggestions are implemented.
 
 
5 hours later…
3:00 PM
Welcome to APL Quest 2014-10! Today's quest is Sales Are Up:
> Given a vector representing monthly sales figures, write a dfn that returns the greatest percent month to month increase.
 
 {∨/0=v:999 ⋄ 100×⌈/(¯1↓⍵)÷⍨-2-/⍵}
 
I found it a bit hard to understand what the percentage would relative to.
Huh, the reference solution is bad?
 
What do you mean?
 
Basically, I mean the question if you need ¯1↓ or 1↓
 
ovs
I had {100-⍨100×⌈/¯2÷/⍵}, which would fail like the reference solution on cases with 0s
 
3:03 PM
Same issue with my 100⌈.ׯ2(-÷⊢)/⊢
 
 (⌈/100×(-2-/⊢)÷¯1↓⊢)
 
I vote for removing test cases with 0s.
@Richard Btw, you can use ¯2-/ to reverse the the segments before their reductions.
(or use -⍨)
 
ah, ok. like I did with the dfn?
 
Does it really make sense to have negative sales?
@Richard Yeah.
 
@Adám I didn't manage to make it tacit, and swapped it again.
 
ovs
3:07 PM
@Adám I don't think so. 0 sales would make more sense, but cause more inconvenience :/
 
@Richard But that is tacit.
 
(was home work from @xpqz ;))
 
@ovs The text doesn't specify what should happen when going from 0 to something.
 
@Adám depends - could be you've bought something. That's how I first thought of negative numbers, that you owe someone something
 
Then what is the correct solution according to the practice problems page? Also catching the 0 gives the same error, instead of telling what the result should have been
 
3:10 PM
Sure, but if so, then it doesn't make sense to month to month increase, does it?
@Richard Yeah, even the internal reference solution doesn't handle it.
 
APL (Dyalog APL), 35 bytes: f←⌈/2{100×⍵÷⍨⍵-⍺}/⊢
why is the precision trash?
 
OK, I've updated the test cases to be strictly positive.
13 mins ago, by Adám
I found it a bit hard to understand what the percentage would relative to.
 
yes is working now
 
@PyGamer0 For golfing purposes, that's 17 bytes.
 
@Adám oh
APL (Dyalog APL), 19 bytes: f←⌈/2{100×⍺÷⍨⍵-⍺}/⊢
@Adám forgot to change the encoding :p
 
3:16 PM
You don't need to count the assignment, per CGCC rules.
 
yea
i know
 
Can anyone beat my 15?
It should really be phrased as 100⌈.ׯ2(-÷⊢)⌿⊢ or ⌈⌿100ׯ2(-÷⊢)⌿⊢ to be leading-axis oriented.
 
ngn/k, 20 bytes: |/{100*(y-x)%x}/'2':
 
You can save one byte in dzaima/APL as it allows omitting the trailing
 
ovs
@Adám 14: 100×1⌈.-⍨¯2÷⌿⊢
 
3:21 PM
Wow.
How does this work? (Simpler to explain ⌈/100×1-⍨¯2÷⌿⊢)
Same principle as your earlier {100-⍨100×⌈/¯2÷/⍵} but I don't get it.
 
Adeline gives: (100×(( ¯2÷⌿⍵)⌈.-1))
 
ovs
(a÷b)-1 is the same as (a-b)÷b
Then its just the same as yours
 
@awagga It doesn't explain‽ ;-)
 
Heh..
 
@ovs I see, but I must have forgotten basic arithmetic or something, because I still don't understand.
 
ovs
3:28 PM
¯2(-÷⊢)⌿⊢¯2{(⍺-⍵)÷⍵}⌿⊢2{(⍺÷⍵)-⍵÷⍵}⌿⊢2{(⍺÷⍵)-1}⌿⊢1-⍨2{⍺÷⍵}⌿⊢1-⍨2÷⌿⊢
This would be how you could derive it from yours, but ÷/ was just my first thought when I read the problem
 
D'oh. Of course.
Leaving golfing, and thinking about efficiency…
I would guess that 100ׯ2(⌈/-/÷⊢/)⊢ would be fastest.
Whoa:
         n←?⍴⍨1e6
  (100ׯ2(⌈/-/÷⊢/)⊢)n → 4.3E¯3 |     0% ⎕
  (100⌈.ׯ2(-÷⊢)/⊢)n  → 2.5E¯1 | +5738% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
@Richard You win the performance price.
 
well... , :)
 
ovs
(100×1-⍨(⌈/¯2÷/⊢))n is 34% faster for me
 
Oh wow, by me too. Why is that?
Oh, what's with me today‽ It only does a single pass.
I like {100ׯ1+⌈/¯2÷/⍵} the most, then.
 
3:45 PM
@Adám yes, agreed
 
Anything else we can say about this?
OK, then that concludes the 2014 problem set. See you next week for 2015-1: Nag A Ram.
 
4:09 PM
@Adám what?
 
 
1 hour later…
5:28 PM
Hello everyone! I have a stupid question about the power operator ⍣. I would like to run my fun ← {?10} 10 times and I try fun⍣10 which results in nested vector of function, operator and 10. Not sure why it doesn't work.
 
@PyGamer0 (a-b)÷b = ((a-b)÷b)÷(b÷b) = ((a÷b)-(b÷b))÷1 = (a÷b)-1
@minerals It just shows you the derived function. You have to give it an argument to run it (even if the argument isn't used).
Btw, (fun⍣10)'dummy arg' does generate 10 random numbers, but you'll never see any of them other than the last generated one.
 
ah, I see. Yes, it gives me the last one (which makes sense), aand I forgot about 10?10 :)
 
@minerals They are not the same. ?10⍴10 generates ten independent 10-sided dice rolls, while 10?10 deals ten unique cards from a 10-card deck.
 
5:54 PM
@Adám ok, that's good to know. I guess ?10⍴10 and ?⍳10 are equivalent.
 
6:08 PM
For some reason, ¯2⊢/80 100 120 140 is returning 100 120 140 instead of 80 100 120 for me.
Is this an old bug? I'm on version 18.0.40684.
 
@minerals they're not. The latter's first item is always 1, the second is either 1 or 2, the third is 1, 2, or 3, etc
@rabbitgrowth yes, that does appear to be a bug; It's fixed in 18.2
 
6:24 PM
Thanks, I was baffled as to why Adám's solution wasn't giving the right result for me
 

« first day (1969 days earlier)      last day (688 days later) »