Skip to content

Instantly share code, notes, and snippets.

Mark Elston melston

  • San Jose, CA
Block or report user

Report or block melston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Alternative FizzBuzz in F# using List.Choose
let fizzbuzz2 rules n =
rules
|> List.choose
(fun (k, s) ->
match n % k with
| 0 -> Some s
| _ -> None )
|> function
| [] -> sprintf "%d" n
| e -> List.reduce (+) e
View Alternative FizzBuzz in F#
let genFB (v: int, s: string) =
fun (n, os) ->
match n%v with
| 0 -> (n, os+s)
| _ -> (n, os)
let getStr (v: int, s: string) =
if (String.length s > 0) then s else sprintf "%i" v
let fizzbuzz max =
@melston
melston / gist:8dcfb2e26de693f5c1eaee42ca682e48
Last active Nov 15, 2017
Another alternative FizzBuzz in F#
View gist:8dcfb2e26de693f5c1eaee42ca682e48
let cycle x = Seq.initInfinite (fun _ -> x) |> Seq.concat
let zipWith f xs ys = Seq.zip xs ys |> Seq.map (fun (x,y) -> f x y)
let fizz = seq ["";"";"fizz"] |> cycle
let buzz = seq ["";"";"";"";"buzz"] |> cycle
let bang = seq ["";"";"";"";"";"";"bang"] |> cycle
let boom = seq ["";"";"";"";"";"";"";"";"";"";"boom"] |> cycle
let numbers = seq [1 .. 115] |> Seq.map string
let fizzBuzz3 = zipWith (+) bang boom
|> zipWith (+) buzz
You can’t perform that action at this time.