「Fizz Buzz」の版間の差分
ページの作成:「'''Fizz Buzz'''(フィズ・バズ、'''Bizz Buzz''' や '''Buzz''' とも呼ばれる)とは、英語圏で長距離ドライブ中や飲み会の時に行われ...」 |
|||
| 44行目: | 44行目: | ||
|m 3 = "fizz" | |m 3 = "fizz" | ||
|True = show n where m x = mod n x == 0 in map f [1..100] | |True = show n where m x = mod n x == 0 in map f [1..100] | ||
</source> | |||
===F#=== | |||
[[F Sharp|F#]]による実装。 | |||
<source lang="fsharp"> | |||
[1..100] | |||
|> Seq.map (function | |||
| x when x%5=0 && x%3=0 -> "FizzBuzz" | |||
| x when x%3=0 -> "Fizz" | |||
| x when x%5=0 -> "Buzz" | |||
| x -> string x) | |||
|> Seq.iter (printfn "%s") | |||
</source> | </source> | ||