Created
January 23, 2010 16:01
-
-
Save kowey/284659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Rabhi and Lapalme, Algorithms: A Functional Programming Approach, pg 80 | |
data BinTree a = Empty | NodeBT a (BinTree a) (BinTree a) deriving Show | |
ex = NodeBT 42 (NodeBT 4 Empty Empty) (NodeBT 2 Empty Empty) | |
comp'' x Empty = (Empty, 0) | |
comp'' x (NodeBT v lf rt) = ( NodeBT (fromIntegral v / fromIntegral x) p1 p2 | |
, v + s1 + s2 ) | |
where | |
(p1,s1) = comp'' x lf | |
(p2,s2) = comp'' x rt | |
comp' t = t' | |
where (t',x) = comp'' x t | |
-- I have a hard time with the 'x' here (in t',x) | |
-- is that tying the knot? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment