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: 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)
  • Re: More elegant way to cwd?
    ... > Is there a more elegant way to change the working directory of Python ... That depends on how you define "elegant", ... It seems like it could be shorter, ... package, that I could then use in code that would magically ...
    (comp.lang.python)
  • Re: specific remove
    ... What I like about Lisp is that even when your code is working it's fun ... to go back and make it shorter, more elegant or more generic. ...
    (comp.lang.lisp)