Use structure format display complex structure

Category:
Format
Description: Use structure format display complex structure
Code:
[<StructuredFormatDisplayAttribute("Tree {Contents}")>]
type Tree(node: int, elems: Tree list) =
member x.Contents = (node, elems)

let printfnSample1() =
let c = Tree (1, [ Tree (2, []); Tree (3, [ Tree (4, []) ]) ])
let c2 = Tree (1, [ c; c])
let c3 = Tree (1, [ c2; c2])
printfn "%A" c3

Execution Result:
Tree (1,
[Tree (1,
[Tree (1, [Tree (2, []); Tree (3, [Tree (4, [])])]);
Tree (1, [Tree (2, []); Tree (3, [Tree (4, [])])])]);
Tree (1,
[Tree (1, [Tree (2, []); Tree (3, [Tree (4, [])])]);
Tree (1, [Tree (2, []); Tree (3, [Tree (4, [])])])])])

Last edited Sep 14, 2011 at 3:12 AM by ttliu2000, version 1

Comments

No comments yet.