Skip to content

Instantly share code, notes, and snippets.

@c-cube
Created December 15, 2017 12:56
Show Gist options
  • Save c-cube/d751398c4897df5f42104717e847960b to your computer and use it in GitHub Desktop.
Save c-cube/d751398c4897df5f42104717e847960b to your computer and use it in GitHub Desktop.
fizbuzz using `sequence` in OCaml
Sequence.(1--100
|> map (fun n->n,if n mod 3=0 then "fiz" else "")
|> map (fun (n,s) -> n, if n mod 5=0 then s^"buzz" else s)
|> map (function (n,"") -> string_of_int n|(_,s) -> s)
|> iter print_endline);;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment