Schwartzian transform

Abigail abigail at abigail.be
Wed Aug 13 12:14:20 BST 2014



Considering you wanted to golf, here's my entry [0]:


map$$ref{s/..//r}{position}=++$::x,sort+map"$$ref{$_}{position},$_",keys%$ref



Now, this will break if the value "position" field of the original structure
is outside of the range 0..9 [1], but that isn't the case in your example.

It makes use of the Guttman-Rossler Transform instead of the Schwartzian
Transform [2].


[0] It gives one warning if they are enabled; I expected more.
[1] Fixing the case where position could be larger than 9, smaller than 0,
    or not an integer is left as an excercise for the reader.
[2] Because you know, we need all the speed when sorting 4 items.



Abigail


More information about the london.pm mailing list