From 8ea7effa639a0640b38917a9f575aedebcdd2b78 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 29 May 2017 22:25:03 -0400 Subject: finish v6 --- 54a-60/55.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 54a-60/55.hs (limited to '54a-60/55.hs') 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 -- cgit v1.2.3-70-g09d2