List.fold_rightnot tail-recursiveas indicated here http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html
List.fold_right
tail-recursive
My question is: why was List.fold_rightnot implemented how tail-recursive?
I think itβs not difficult to do.
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;;
I also found a number of non functions in the library tail-recursive, while they can be implemented as tail-recursive. How did the manufacturer make such decisions?
fold_right , , . , ( , ) , .
fold_right
, fold_right .. , , Extlib . , , non-tailrec , tailrec, , - cons ( ).
, , . :
OCaml std lib - ?
, . , , .