{"id":27,"date":"2007-07-28T21:48:51","date_gmt":"2007-07-29T04:48:51","guid":{"rendered":"http:\/\/www.elbeno.com\/haskell_soe_blog\/?p=27"},"modified":"2008-01-07T22:07:42","modified_gmt":"2008-01-08T06:07:42","slug":"exercise-73","status":"publish","type":"post","link":"https:\/\/www.elbeno.com\/haskell_soe_blog\/?p=27","title":{"rendered":"Exercise 7.3"},"content":{"rendered":"<pre lang=\"haskell\">foldrTree :: (a -> b -> b) -> b -> InternalTree a -> b\r\nfoldrTree f z ILeaf = z\r\nfoldrTree f z (IBranch a x y) = foldrTree f (f a (foldrTree f z y)) x\r\n\r\nfoldlTree :: (a -> b -> a) -> a -> InternalTree b -> a\r\nfoldlTree f z ILeaf = z\r\nfoldlTree f z (IBranch a x y) = foldlTree f (f (foldlTree f z x) a) y\r\n\r\nrepeatTree :: a -> InternalTree a\r\nrepeatTree a = t\r\n    where t = (IBranch a (t) (t))<\/pre>\n<p><tt>repeatTree<\/tt> is apparently magic: the base case constructor (<tt>ILeaf<\/tt>) is not specified. But the <tt>takeTree<\/tt> and <tt>takeTreeWhile<\/tt> functions work with <tt>repeatTree<\/tt> as expected.<\/p>\n<p>(<a href=\"http:\/\/haskell.org\/soe\/Bug\/erata.htm\">Technical error 14<\/a> applies to this exercise.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>foldrTree :: (a -> b -> b) -> b -> InternalTree a -> b foldrTree f z ILeaf = z foldrTree f z (IBranch a x y) = foldrTree f (f a (foldrTree f z y)) x foldlTree :: (a -> b -> a) -> a -> InternalTree b -> a foldlTree f z ILeaf [&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\/27"}],"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=27"}],"version-history":[{"count":0,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}