首页 > Ocaml 中序遍历
头像
KentWong
发布于 2020-05-18 03:00
+ 关注

Ocaml 中序遍历

let in_order tree  =
  let rec aux tree accumulator =
    match tree with
    | Nil -> accumulator
    |Member (left, value, right) -> 
      let acc_with_right = aux right accumulator  in
      let acc_with_value =  value :: acc_with_right  in
      aux left acc_with_value in
  aux tree [] 
给大家分享一下一个Ocaml 写 中序遍历的写法,中序遍历是左中右。

全部评论

(0) 回帖
加载中...
话题 回帖

相关热帖

近期热帖

近期精华帖

热门推荐