Re: [Golf-ish] Ordered hash keys



Damian James <djames@xxxxxxxxxxxxx> wrote:

> my @fields = @mappings[ map $_*2, 0..($#mappings/2) ];

> Is there a simpler, shorter
> or more elegant 'hashificator' that might be suitable in place of the
> arithmetic one I've shown?


You can save 3 strokes by generating the slice indexes with:

grep $_%2, 0..$#mappings

instead of map().


--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.



Relevant Pages

  • Re: [Golf-ish] Ordered hash keys
    ... shorter ... >> or more elegant 'hashificator' that might be suitable in place of the ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: parsing a CSV line
    ... > quote text qualifier and backslashes. ... > was wondering if there might be a more elegant or shorter way: ...
    (comp.lang.lisp)
  • RE: IF/OR/AND function in a formula
    ... If I am reading the problem correctly, ... Luke's formula is shorter and, therefore, more elegant, but it adds E and F, ... equals 0 then the result should be E - F. Please help. ...
    (microsoft.public.excel.misc)
  • Re: Casting of void pointer returned by malloc()
    ... is surely shorter, neater, safer, more elegant than ... definitely safer, at least in the sense of "more easy to maintain". ...
    (comp.lang.c)