diff options
author | Determinant <[email protected]> | 2017-05-29 22:25:03 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2017-05-29 22:25:03 -0400 |
commit | 8ea7effa639a0640b38917a9f575aedebcdd2b78 (patch) | |
tree | 7916f64813dc89459ae62add344778fedafb3872 /54a-60/55.hs | |
parent | d0aa856bedb0c0223b4ce2a67f5582b8eadf3682 (diff) |
finish v6
Diffstat (limited to '54a-60/55.hs')
-rw-r--r-- | 54a-60/55.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/54a-60/55.hs b/54a-60/55.hs new file mode 100644 index 0000000..5cc7b91 --- /dev/null +++ b/54a-60/55.hs @@ -0,0 +1,13 @@ +data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq) + +cbalTree :: Int -> [Tree Char] + +cbalTree 0 = [Empty] +cbalTree x + | even n = [Branch 'x' lt rt | let st = cbalTree ln, lt <- st, rt <- st] + | otherwise = let st1 = cbalTree ln + st2 = cbalTree (n - ln) in + [Branch 'x' lt rt | lt <- st1, rt <- st2] ++ + [Branch 'x' lt rt | lt <- st2, rt <- st1] + where ln = n `div` 2 + n = x - 1 |