diff options
author | Determinant <ted.sybil@gmail.com> | 2017-05-30 01:28:36 -0400 |
---|---|---|
committer | Determinant <ted.sybil@gmail.com> | 2017-05-30 01:28:36 -0400 |
commit | 626a548f0ef51b5ee1d3ba049330317f94c89f99 (patch) | |
tree | 3ac0d4146e156a64ffe81fd2578ff6638f9fc7f5 /61-69/64.hs | |
parent | 8ea7effa639a0640b38917a9f575aedebcdd2b78 (diff) |
...
Diffstat (limited to '61-69/64.hs')
-rw-r--r-- | 61-69/64.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/61-69/64.hs b/61-69/64.hs new file mode 100644 index 0000000..7b7aedd --- /dev/null +++ b/61-69/64.hs @@ -0,0 +1,10 @@ +data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq) + +layout :: Tree Char -> Tree (Char, (Int, Int)) + +layout t = fst $ draw t 1 1 + where draw Empty x _ = (Empty, x) + draw (Branch v l r) x y = + (Branch (v, (x', y)) lt rt, x'') + where (lt, x') = draw l x (y + 1) + (rt, x'') = draw r (x' + 1) (y + 1) |