書き捨てPerl #1 grep block map
# 素数だけ出力(grepでブロック式を使用) my @prime = grep { my $num = $_; my $count = 0; map {$num % $_ ? 0 : $count++ } 1..$num; $count == 2 ; } 1..100; say "@prime";
# 素数だけ出力(grepでブロック式を使用) my @prime = grep { my $num = $_; my $count = 0; map {$num % $_ ? 0 : $count++ } 1..$num; $count == 2 ; } 1..100; say "@prime";