Skip to content

Instantly share code, notes, and snippets.

@h1romas4
Last active March 10, 2020 08:26
Show Gist options
  • Save h1romas4/1b1cdc75dc852303f28c33061782536d to your computer and use it in GitHub Desktop.
Save h1romas4/1b1cdc75dc852303f28c33061782536d to your computer and use it in GitHub Desktop.
PowerShell 7 の新機能 ForEach-Object -Parallel を使った シャー専用 3並列パラレル FizzBuzz
# -Parallel で並列化
# -ThrottleLimit で立てるスレッド数を指定
1..100 | foreach -ThrottleLimit 3 -Parallel {
# 最短 FizzBuzz は http://blog.powershell-from.jp/?p=15 さんより
$s=@(“Fizz”)[$_%3] + @(“Buzz”)[$_%5];
[PSCustomObject]@{
Id =$_; Value = ($s,$_)[!$s]
}
} | Sort-Object Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment