I have this OCaml program
open Core.Std;;
open Printf;;
let all l = List.fold ~f:(&&) ~init:true l;;
let any l = List.fold ~f:(||) ~init:false l;;
let main () = let bools = [true; false; true; true; false; true] in
printf "%b %b\n" (all bools) (any bools);;
main();;
And then two make files, the first is
all: a.out
@true
a.out: fold.cmx
ocamlfind ocamlopt -g -linkpkg -package core -package core_kernel -thread -w -10 fold.cmx
fold.cmx: fold.ml fold.cmi
ocamlfind ocamlopt -g -c fold.cmx -package core -package core_kernel -thread -w -10 fold.ml
fold.cmi: fold.mli
ocamlfind ocamlopt -g -c -package core -package core_kernel -thread -w -10 fold.mli
fold.mli: fold.ml
ocamlfind ocamlc -i -package core -package core_kernel -thread -w -10 fold.ml > fold.mli
clean:
@rm *.cmx *.cmi *.o tests 2>/dev/null || true
Which produces an a.out that gives the expected output of false true
.
The second is
all: fold
@true
fold: fold.cmx
ocamlfind ocamlopt -g -o fold -linkpkg -package core -package core_kernel -thread -w -10 fold.cmx
fold.cmx: fold.ml fold.cmi
ocamlfind ocamlopt -g -c fold.cmx -package core -package core_kernel -thread -w -10 fold.ml
fold.cmi: fold.mli
ocamlfind ocamlopt -g -c -package core -package core_kernel -thread -w -10 fold.mli
fold.mli: fold.ml
ocamlfind ocamlc -i -package core -package core_kernel -thread -w -10 fold.ml > fold.mli
clean:
@rm *.cmx *.cmi *.o tests 2>/dev/null || true
which produces a fold that on my machine, hangs without output. The only difference between the two is that one of them puts its output in fold and the other puts it in a.out. The version numbers for my ocaml, ocamlc, ocamlopt, and ocamlfind are all 4.02.1 and opam show core
says it's version 112.06.01. Any of you guys know what's causing the difference?
You are running the standard fold program. Try ./fold.