{"id":26,"date":"2007-07-28T21:43:41","date_gmt":"2007-07-29T04:43:41","guid":{"rendered":"http:\/\/www.elbeno.com\/haskell_soe_blog\/?p=26"},"modified":"2008-01-07T22:07:08","modified_gmt":"2008-01-08T06:07:08","slug":"exercise-72","status":"publish","type":"post","link":"https:\/\/www.elbeno.com\/haskell_soe_blog\/?p=26","title":{"rendered":"Exercise 7.2"},"content":{"rendered":"<pre lang=\"haskell\">data InternalTree a = ILeaf\r\n                    | IBranch a (InternalTree a) (InternalTree a)\r\n                      deriving Show\r\n\r\ntakeTree :: Int -> InternalTree a -> InternalTree a\r\ntakeTree 0 t = ILeaf\r\ntakeTree n ILeaf = ILeaf\r\ntakeTree n (IBranch a x y) = IBranch a (takeTree (n-1) x) (takeTree (n-1) y)\r\n\r\ntakeTreeWhile :: (a -> Bool) -> InternalTree a -> InternalTree a\r\ntakeTreeWhile f ILeaf = ILeaf\r\ntakeTreeWhile f (IBranch a x y) = if (f a)\r\n                                  then IBranch a (takeTreeWhile f x)\r\n                                                 (takeTreeWhile f y)\r\n                                  else ILeaf<\/pre>\n<p>(<a href=\"http:\/\/haskell.org\/soe\/Bug\/erata.htm\">Technical error 13<\/a> applies to this exercise.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>data InternalTree a = ILeaf | IBranch a (InternalTree a) (InternalTree a) deriving Show takeTree :: Int -> InternalTree a -> InternalTree a takeTree 0 t = ILeaf takeTree n ILeaf = ILeaf takeTree n (IBranch a x y) = IBranch a (takeTree (n-1) x) (takeTree (n-1) y) takeTreeWhile :: (a -> Bool) -> InternalTree [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":0,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}