f_map.t

Code test snippets here are adapted from `perldoc -f map`

# chunk: #!perl # examples shamelessly snatched from perldoc -f map

# chunk: # translates a list of numbers to the corresponding characters. @chars = map(chr, @nums);

# chunk: %hash = map { getkey($_) => $_ } @array;

# chunk: { %hash = (); foreach $_ (@array) { $hash{getkey($_)} = $_; } }

# chunk: #%hash = map { "\L$_", 1 } @array; # perl guesses EXPR. wrong %hash = map { +"\L$_", 1 } @array; # perl guesses BLOCK. right

# chunk: %hash = map { ("\L$_", 1) } @array; # this also works

# chunk: %hash = map { lc($_), 1 } @array; # as does this.

# chunk: %hash = map +( lc($_), 1 ), @array; # this is EXPR and works!

# chunk: %hash = map ( lc($_), 1 ), @array; # evaluates to (1, @array)

# chunk: @hashes = map +{ lc($_), 1 }, @array # EXPR, so needs , at end