📜  fold_tree ocaml - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:12.244000             🧑  作者: Mango

代码示例1
type 'a tree = 
  | Node of 'a tree * 'a * 'a tree
  | Leaf;;

let rec fold_tree f a t = 
    match t with
      | Leaf -> a
      | Node (l, x, r) -> f x (fold_tree f a l) (fold_tree f a r);;