You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code demonstrates inconsistent behavior between the List.init function in Base and the same function in the OCaml standard library due to an incorrect evaluation order of list elements:
openPrintfopenBaselet()=
printf "Stdlib:\n\n";
let r =ref0inStdlib.List.init 10 (fun_i -> Int.incr r; !r) |>List.iter ~f:(printf "%d\n")
let()=
printf "\n\nJane Street:\n\n";
let r =ref0inList.init 10~f:(fun_i -> Int.incr r; !r) |>List.iter ~f:(printf "%d\n")
The following code demonstrates inconsistent behavior between the
List.init
function inBase
and the same function in the OCaml standard library due to an incorrect evaluation order of list elements:Output:
Note that the standard library uses
[@tail_mod_cons]
to achieve tail recursion without having to reverse the list.The text was updated successfully, but these errors were encountered: