simplify to_string
This commit is contained in:
1 file changed
+2
-5
@@ -130,13 +130,10 @@ module Make(Ord: OrderedType) = struct
|
|||||||
(** [to_string f t] takes a function [f] to "convert" a
|
(** [to_string f t] takes a function [f] to "convert" a
|
||||||
* key-value pair to a string, and applies that to all
|
* key-value pair to a string, and applies that to all
|
||||||
* key-value pairs in a given tree [t]. *)
|
* key-value pairs in a given tree [t]. *)
|
||||||
let to_string f t =
|
let rec to_string f t =
|
||||||
let rec aux t =
|
|
||||||
match t with
|
match t with
|
||||||
| L -> "#"
|
| L -> "#"
|
||||||
| N (k, v, l, r) ->
|
| N (k, v, l, r) ->
|
||||||
Printf.sprintf "^(%s, %s, %s)" (f (k, v)) (aux l) (aux r)
|
Printf.sprintf "^(%s, %s, %s)" (f (k, v)) (to_string f l) (to_string f r);;
|
||||||
in
|
|
||||||
aux t;;
|
|
||||||
|
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user