General

Haskell Adventures #1

Ok so Haskell is now my new interest and I have been reading the Real Work Haskell Book and so far so good. Wrote my first haskell program that I am satisfied with.

data Tree a = Node a (Tree a) (Tree a)
            | Empty
            deriving (Show)

treeHight Empty = 0
treeHight (Node _ Empty Empty) = 1
treeHight (Node _ x y) = 1 + max (treeHight x) (treeHight y)

One thought on “Haskell Adventures #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s