Why does the OCaml std lib have so many non-tail-recursive functions?

后端 未结 2 1961
礼貌的吻别
礼貌的吻别 2021-02-19 20:55

I have been rewriting many OCaml standard library functions to be tail-recursive lately. Given that this has entailed straight-forward CPS transformation, I am left puzzling ov

2条回答
  •  执念已碎
    2021-02-19 21:02

    In my experience, tail recursive versions of non-trivial functions often trade space efficiency against time efficiency. In other words, the functions in the standard library might easily be faster for smallish inputs.

提交回复
热议问题