OCaml で FizzBuzz 書けた

open List;;

let rec iota ?(step=1) ?(n=0) m =
  if n > m then []
  else n :: iota ~n:(n + step) m ~step
;;

let isFizz n =
  ( n mod 3 ) == 0
;;

let isBuzz n =
  ( n mod 5 ) == 0
;;

let isFizzBuzz n =
  (isFizz n) && (isBuzz n)
;;

let toFizzBuzz n =
  if (isFizzBuzz n) then
    "FizzBuzz"
  else if (isFizz n) then
    "Fizz"
  else if (isBuzz n) then
    "Buzz"
  else
    string_of_int n
;;

let main () =
  let fizzbuzz = List.map toFizzBuzz (iota 100) in
  List.iter print_endline fizzbuzz
;;

  main ();;