Skip to content

Instantly share code, notes, and snippets.

@bruno-cadorette
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save bruno-cadorette/dd85bb4b8c886ca64d72 to your computer and use it in GitHub Desktop.

Select an option

Save bruno-cadorette/dd85bb4b8c886ca64d72 to your computer and use it in GitHub Desktop.
fizzbuzz with infinite list, without modulo
fizzbuzz xs =
let
fizz = cycle ["","","fizz"]
buzz = cycle ["","","","","buzz"]
f x i = if null x then show i else x
in
zipWith3 (\fz bz i-> f (fz++bz) i) fizz buzz xs
main = do
putStr $ unlines $ fizzbuzz [1..100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment