OCaml cons (::) operator?

11 No. Cons (::) is a constructor, constructors can not be infix operators. The allowed infix symbols are here: http://caml.inria.fr/pub/docs/manual-caml-light/node4.9.html Some workarounds are (as you mention) the verbose and defining your own nontraditional infix cons

“Error: unbound module” in OCaml

You have several options depending on your needs. 1) If you want to create a full project for your binary I recommend looking at jbuilder. Here is a very nice guide that explains the environment/project configuration step-by-step: OCaml for the impatient. 2) Another option is to compile the binary directly as you were trying to … Read more

Print a List in OCaml

You can do this with a simple recursion : The head of the list is printed, then you do a recursive call on the tail of the list.

List.fold_left in OCaml

fold_left operates on lists, as your function does, by applying a function and accumulating a result in a particular manner. It takes care of and abstracts the recursion for you. It deals with the structure of the list, so you can deal with how to combine the elements of the list in a particular manner. So, … Read more