How do you write af# recursive data types that define a parametric data
type Three <'a>
that calls output:
Node (1,Node (2,Leaf,Leaf),Node (3,Node (4,Leaf,Leaf),Leaf))
if I input:
let tree = Node(1, Node(2, Leaf, Leaf), Node(3, Node(4, Leaf, Leaf), Leaf))
tree
You can use this to define a tree. Leaf in your question is called Empty here.
type Tree<'a> = Empty | Node of Tree * 'a * Tree
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.