FizzBuzz
F#

F#'s cool FizzBuzz (^_^)b

Summary

F#でいい感じのFizzBuzzができた(ような気がする)

F#FizzBuzz書いてみてと急に言われても安心

Thanks

@haxe
@omanuke
@bleis

Code

[
    ["fizz";"";""]
    ["buzz";"";"";"";""]
]
|> List.map ( fun l -> Seq.initInfinite( fun _ -> l ) |> Seq.concat )
|> function a::b::_ -> Seq.zip a b | _ -> failwith "invalid!"
|> Seq.mapi ( fun i (a,b) -> if a + b = "" then string i else a + b )
|> Seq.tail
|> Seq.take 100
|> Seq.iter stdout.WriteLine

結果

1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
16
17
fizz
19
buzz
fizz

Point

// いつか書く

reference

taediumの日記

sudo rm -rf /

fsharp掲示板