Created
August 17, 2014 05:01
-
-
Save mackee/642fe4cd7d88d2610d5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my @input_numbers = (1, 2, 4, 8, 16, 32, 64); | |
my @result = map { | |
my @digits = split //,$_; # $_を文字列として1文字ずつに分解する => 桁ごとに分解 | |
if ($digits[-1] == 4) { # 一番最期の桁(=1の位)の桁がもし4であれば | |
@digits; #すべての桁をリストとして返す | |
} else { #そうでなければ | |
(); # なにも返さない | |
} | |
} @input_numbers; | |
# => (4, 6, 4) | |
foreach (@result) { | |
say; | |
} | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment