On Fri, May 22, 2009 at 5:34 AM, Timothy S. Nelson <wayl...@wayland.id.au> wrote: > On Fri, 22 May 2009, Jonathan Worthington wrote: > >> Daniel Ruoso wrote: >>> >>> Em Sex, 2009-05-22 às 01:25 -0500, John M. Dlugosz escreveu: >>> >>>> �...@primes = do $_ if prime($_) for 1..100; >>>> becomes >>>> �...@primes = $_ when prime($_) for 1..100; >>>> >>> >>> >>> you gained one stroke, it's certainly better... I think it's time to >>> play golf with Perl 6 already ;) >>> >>> jokes aside, "$_ when prime($_)" looks more natural than "do $_ if >>> prime($_)" >>> >>> >> Yes and: >> >> @primes = 1..100.grep: { prime($^n) }; >> >> Is actually vaguely, like, readable AND two characters shorter than the >> best you've managed so far. > > Oh, if we're looking for readability, I'd look for: > > 1..100.grep: { prime($^n) } ==> @primes; > > It's longer, though :).
These are only readable if you know geek-speak (i.e., "what does 'grep' mean?"). The alternatives being proposed are using words like "do", "if", "when", and "for". I think that it's rather impressive that they're coming within a handful of characters of a grep-based version. -- Jonathan "Dataweaver" Lang