develooper Front page | perl.fwp | Postings from May 2012

Re: seeking golfing advice

Thread Previous | Thread Next
From:
Pau Amma
Date:
May 16, 2012 05:52
Subject:
Re: seeking golfing advice
Message ID:
b61f2f8efd11756cd1a7ecfc4ff9909d.squirrel@www.gundo.net
On Wed, May 16, 2012 12:25 pm, damien krotkine wrote:
> On 16 May 2012 14:02, Peter Makholm <peter@makholm.net> wrote:
> [ ... ]
>
>> So basically you are trading 8 characters for readability and probably
>> speed. Why do you want that?
>
> For fun, purely. I'll stick with $f % 2 for now, it seems a right
> balance compared to the code lying around.

If, as it sounds, you want to balance golfiness and strictness, you could
also say:

@array[grep $_%2, keys @array]

(or @array[grep $_%2^1, keys @array] if you set $[ to 1 - but you didn't
do that, right? :-) )


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About