Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type 'a bin_tree =
- Node of 'a bin_tree * 'a * 'a bin_tree | Nil ;;
- let bf_iter f = function
- Nil -> ()
- | root ->
- let q = ref [root] in
- while !q <> [] do
- let this = match !q with h :: _ -> h | _ -> Nil
- in let _ = q := match !q with _ :: t -> t | _ -> []
- in match this with
- Node (l, e, r) -> f e; q := !q @ [l; r]
- | _ -> ()
- done ;;
Add Comment
Please, Sign In to add comment