Last active
March 10, 2020 08:26
-
-
Save h1romas4/1b1cdc75dc852303f28c33061782536d to your computer and use it in GitHub Desktop.
PowerShell 7 の新機能 ForEach-Object -Parallel を使った シャー専用 3並列パラレル FizzBuzz
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
# -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