Skip to main content

in reply to Mark Gardner

@lkundrak But if you wanted to be cute like @nedbatโ€™s #Python example, the #Perl one-liner is:

perl -MList::Util=sum -E 'say sum map $_ ** 3, 2..9'

in reply to Mark Gardner

@mjgardner @lkundrak It may "waste" a character but i'd always write that as

map {$_**3} 2..9

because the braces make the deferred nature of the map expression really obvious. The comma form is way too subtle for casual users.

in reply to Paul Evans

Fair point but I didnโ€™t use the comma because I was golfing. I did it because it was a one-liner that might be retyped and I didnโ€™t want confusion between braces and parens when theyโ€™re being eyeballed in the default #Mastodon proportional font (Roboto) or worse.

/cc @lkundrak, @nedbat

in reply to Mark Gardner

@mjgardner @lkundrak Perl is really not the language to be writing if your font has legibility issues between () and {} ;)
โ‡ง