f_map
来自「source of perl for linux application,」· 代码 · 共 30 行
TXT
30 行
#!perl# examples shamelessly snatched from perldoc -f map# translates a list of numbers to the corresponding characters.@chars = map(chr, @nums);%hash = map { getkey($_) => $_ } @array;{ %hash = (); foreach $_ (@array) { $hash{getkey($_)} = $_; }}#%hash = map { "\L$_", 1 } @array; # perl guesses EXPR. wrong%hash = map { +"\L$_", 1 } @array; # perl guesses BLOCK. right%hash = map { ("\L$_", 1) } @array; # this also works%hash = map { lc($_), 1 } @array; # as does this.%hash = map +( lc($_), 1 ), @array; # this is EXPR and works!%hash = map ( lc($_), 1 ), @array; # evaluates to (1, @array)@hashes = map +{ lc($_), 1 }, @array # EXPR, so needs , at end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?