« first day (1521 days earlier)      last day (1134 days later) » 

12:01 AM
@Adám will dyalog scripts have access to argv?
 
12:56 AM
APL Seeds talk finished and first rehearsal done ... clocked in a bit under 30mins. Excited!! :)
 
@MartinJaniczek Nice I'm looking forward to it! Seems like a solid lineup altogether
 
 
2 hours later…
3:25 AM
@MartinJaniczek Good to know
 
 
3 hours later…
6:01 AM
@rak1507 APLcart (I'll add "argv")
 
 
3 hours later…
8:57 AM
@Adám ah, thanks
 
 
2 hours later…
10:34 AM
@Adám I offer the following tweak to the merge function: gist.github.com/xpqz/ecfadd3672168fddf9f8d1d23f20f366
 
 
1 hour later…
11:59 AM
@xpqz I've been planning to write a blog post about 2020's phase 2, but I simply don't have the time. Would you be interested in writing a guest blog post? I'd send you all the best (imo) solutions (which you are free to tweak, like this), and then you can write as much (or little) as you want about each one.
We'd of course help with review etc.
 
Sure, that sounds like fun.
 
@xpqz OK, you should get a notification from Google Docs.
 
12:14 PM
Some interesting stuff there. I wrote up a long thing on the Balance the Scales problem -- I see that Horowitz and Sahni's alg is highlighted. Fast, but not guaranteed to find a perfect solution.
 
12:38 PM
@xpqz Feel free to include what you wrote. The style is completely up to you. If you want to briefly talk about all the problems, and then go into depth about a single one, then that's perfectly fine too.
 
 
1 hour later…
1:51 PM
do you know if dyalog will publish solutions for this years competition?
 
@rak1507 That's exactly what ^^^^^ is about.
 
I mean 2021, not 2020
 
@rak1507 Oh, we always plan to publish something, but you know, stuff happens…
 
2:08 PM
I know you publish the best solutions, but will every winning solution be published? I assume not
 
@Adám do you have a timeline in mind for this blogpost (2020)?
 
3:00 PM
love when you memoise a function and it goes from lots of time to instant
 
 
2 hours later…
4:52 PM
Doing something where ≠ is exactly what I need, but unfortunately I am not working in 18.0 yet. Took a look at aplwiki.com/wiki/Nub_Sieve#APL_models at some ways to implement it in older versions.
Hit a syntax error with the train expressions in 17.1 due to the atop operator changes, and decided to just rewrite using a simple "@" approach. There are nice ways to implement it using ⌽ and = as well, but you need to start handling more edge cases.
I'm guessing the UniqueMask function in there was only for education purposes, the performance on it is terrible. Comparing the other functions mentioned in there vs the @ approach:
  t1 ← (⍳⍤≢=⍳⍨)⍤(∪⍳1/⊢)
  t2 ← (2≠/¯1,⌈\)⍤(∪⍳1/⊢)
  AtUnique←{x←1/⍵ ⋄ i←x⍳∪x ⋄ 1(@i)(≢x)⍴0}
          a ← 1e6 ⍴ ⎕A
          cmpx 'AtUnique a' '≠a' 't1 a' 't2 a'
  AtUnique a → 5.4E¯4 |    0% ⎕⎕⎕⎕
  ≠a         → 2.3E¯3 | +323% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  t1 a       → 4.9E¯3 | +798% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  t2 a       → 3.3E¯3 | +518% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
      sa ← Sort a
      cmpx 'AtUnique sa' '≠sa' 't1 sa' 't2 sa'
  AtUnique sa → 4.7E¯4 |    0% ⎕⎕⎕⎕⎕⎕⎕
  ≠sa         → 4.0E¯5 |  -92% ⎕
  t1 sa       → 2.7E¯3 | +471% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  t2 sa       → 1.5E¯3 | +208% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Sometimes using @ feels like a "cheat". Just thought the results were interesting
 
What's the 1/⍵ for?
 
5:23 PM
@rak1507 To turn a scalar into a vector
So it works on scalar arguments
 
Ah, like ,⍵?
 
Sort of, but , will destroy the structure if you have a matrix
 
5:41 PM
@JoshD Nice! How simple. Bracket indexing is fast, and I think that is simply what @ is doing under the covers in this case. Also, Marshall's v18 implementation of ≠ will beat the @ or bracket index version in other cases. Certainly for a matrix.
Though it looks like for simple vectors maybe a little optimization was left on the shop floor.
 
The reason ≠sa is so fast (25 characters per nanosecond) is that there's a special case for sorted arguments.
AtUnique is applying some even more special methods: both and will be done with lookups on bit tables stored in vector registers. I probably didn't apply that method to . It's not exactly trivial to write and because it can't be branchless the performance is less predictable. It will be slower for short vectors and some medium-length ones, so it's probably only valid to always use it on vectors over 512 elements or so.
Also is doing a reverse lookup so it can build a table on ∪x instead of the much longer x.
 
@Marshall Potentially silly question from a non-implementor: how do you know the argument is sorted?
 
@PaulMansour Sort idioms set a flag bit on the result.
 
5:59 PM
@Marshall So that's right there in the header of the array? Is that a relatively new thing?
 
@PaulMansour Yeah, it was added in 18.0. It wasn't that well supported as of when I left which is why it isn't mentioned in the release notes.
 
@PaulMansour Yeah I only tested my case of simple vectors, will shift over to v18 ≠ when I can, but good to note that
@Marshall I guess that means the optimizations won't happen if you pull in data (say from a file or DB) that is already sorted (E.G. if you have an order by in your query)
 
@JoshD Very cool.
That was for Marshall. But you are cool too Josh.
 
@JoshD It won't test automatically, but if you sort the array (even discarding the result) then it should set the flag bit.
 
Haha thanks :D
 
6:04 PM
And Interval Index has to check that its left argument is sorted so it sets that bit as well.
 
Oh ok, but yes the ≠ results for the sorted array are certainly impressive
 
In the old days, we would sort a matrix and do a shift and compare to flag the first occurrence of each item, and then sort it back. If the array was already sorted, you obviously did not have to sort/resort.
Given:
firstOccuranceSortedMatrix←{
f←∨/⍵≠¯1⊖⍵
f[⍳×⍴f]←1
f
}
What is the trick for a block of code? Markdown?
 
6:23 PM
@PaulMansour ctrl+k
 
  M← {⍵[⍋⍵;]}'ZI15'  ⎕FMT ?1000000⍴10000
     cmpx    '≠M'  'fsm M'
  ≠M    → 1.5E¯2 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  fsm M → 1.2E¯2 | -20% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
(or the fixed font button that shows up when a message is multiline; you can edit that in too of course)
 
Silly me. Found it. Thanks.
@Marshall It appears some 30 year old code still has something to offer!
fsm is firstOccuranceSortedMatrix above.
 
@PaulMansour Well yeah, the trick is not writing the code but writing the code that knows to call it. I probably used a pretty similar method, which might have differences with different shapes, or architectures.
In fact, I get
      cmpx    '≠M'  'fsm M'
  ≠M    → 2.0E¯2 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  fsm M → 2.4E¯2 | +20% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
(first result was a debug interpreter, oops.)
 
@Marshall Indeed. And interesting. I'll be going with ≠ when I finally move to 18.
 
7:19 PM
having learnt APL in v18 I can't imagine ever going back
 

« first day (1521 days earlier)      last day (1134 days later) »