This line of code sorts two arrays in "lock step", according to
the items of the first array:
zip(first, second).sort!q{a[0] < b[0]}();
This code is handy, nice looking, short and sufficiently easy to
recognize once you have seen it before.
It's one case where D code is better than a Python
On Tuesday, 25 September 2012 at 02:17:53 UTC, bearophile wrote:
This line of code sorts two arrays in "lock step", according to
the items of the first array:
zip(first, second).sort!q{a[0] < b[0]}();
Tangential to your point, but I hadn't seen the q{} syntax used
before. Are there reasons t
On 25-Sep-12 06:18, bearophile wrote:
This line of code sorts two arrays in "lock step", according to the
items of the first array:
zip(first, second).sort!q{a[0] < b[0]}();
This code is handy, nice looking, short and sufficiently easy to
recognize once you have seen it before.
Analyzing asm
Dmitry Olshansky:
Analyzing asm dump should help.
In this case it's a good amount of asm code.
But either way zip-sort heavily relies on proper inlining and I
suspect it's not fully "unrolled".
I don't know if that's enough.
Did you try DMD or other compilers?
In past I have used LDC
On 25-Sep-12 15:23, bearophile wrote:
Dmitry Olshansky:
Analyzing asm dump should help.
In this case it's a good amount of asm code.
This sounds like you are not interested in the cause of this at all ;)
I've dig it and it looks mostly fine. However for a small number of
elements it will
Dmitry Olshansky:
This sounds like you are not interested in the cause of this at
all ;)
Right, this I was a little lazy, because I was a bit depressed
because of similar problems. I will do more tests.
Later,
bearophile