Hacker News new | ask | show | jobs
by technomancy 5424 days ago
Curious: is this also valid ocaml?
1 comments

Almost, |> isn't an operator in OCaml (although I think Batteries has something like |- that does the same thing) and printfn isn't in OCaml. Printf.printf is, but wouldn't work in this case (you'd need a format string). Also, List.map returns a new list, in OCaml you would probably want to do List.iter.
the |> operator is very very simple. ocaml implementation would look something like:

  let (|>) a b = b a ;;