RosettaCodeData/Task/Parametric-polymorphism/OCaml/parametric-polymorphism.ocaml

7 lines
225 B
Text
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
type 'a tree = Empty | Node of 'a * 'a tree * 'a tree
(** val map_tree : ('a -> 'b) -> 'a tree -> 'b tree *)
let rec map_tree f = function
| Empty -> Empty
| Node (x,l,r) -> Node (f x, map_tree f l, map_tree f r)