List.fold_right不像tail-recursive这里所说的那样http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html
我的问题是为什么List.fold_right没有实施为tail-recursive?
我认为这样做并不难
let rev l =
let rec revr acc = function
| [] -> acc
| hd::tl -> revr (hd::acc) tl
in
revr [] l;;
let fold_right f l b =
let rev_l = rev l
in
let rec folder_rr acc = function
| [] -> acc
| hd::tl -> folder_rr (f hd acc) tl
in
folder_rr b rev_l;;
我还在库中发现,一些函数tail-recursive虽然可以实现为tail-recursive. 制造商是如何做出这样的决定的?