Schwartzian transform

Abigail abigail at
Wed Aug 13 11:03:26 BST 2014

On Wed, Aug 13, 2014 at 10:50:39AM +0100, Alex Balhatchet wrote:
> Hi Dermot,
> You have a few problems with your code:
> 1. First argument to map is a block

First argument of map is either a block, or an expression.

> You should be wrapping your code block to map with curly braces.
> eg. map { [ $_, $ref->{$_}{position} ] }

No, not required. His code is fine.

> 2. No need to use $ref in your second (chronologically by execution,
> first by line number) map
> The Schwartzian Transform puts the original value into the first
> element of the array reference, so to map back you just take $_->[0].

But then you would end up with a list of keys, his code ends up with a
list of records. Those are different things.

> 3. Some mis-placed commas
> When chaining maps and sorts you don't need commas, because there
> should be no comma separating your block from the next argument to map
> (this is related to my first point.)

This goes back to point one. You don't know map. The commas are actually
required here, as he's using the "map EXPRESSION" syntax.

His code is actually fine, and runs without any modifications.


More information about the mailing list