RosettaCodeData/Task/Parametric-polymorphism/F-Sharp/parametric-polymorphism-1.fs
2023-07-01 13:44:08 -04:00

9 lines
287 B
FSharp

namespace RosettaCode
type BinaryTree<'T> =
| Element of 'T
| Tree of 'T * BinaryTree<'T> * BinaryTree<'T>
member this.Map(f) =
match this with
| Element(x) -> Element(f x)
| Tree(x,left,right) -> Tree((f x), left.Map(f), right.Map(f))