Skip to content

Instantly share code, notes, and snippets.

View RicArch97's full-sized avatar
😃

Ricardo Steijn RicArch97

😃
  • Hunter Douglas Europe B.V.
View GitHub Profile
@mmagm
mmagm / binary-tree.hs
Created May 26, 2012 12:01
haskell binary tree
data BinaryTree a = EmptyTree | Node a (BinaryTree a) (BinaryTree a)
deriving (Show)
treeInsert :: Ord a => a -> BinaryTree a -> BinaryTree a
treeInsert el EmptyTree = Node el EmptyTree EmptyTree
treeInsert el (Node a left right)
| el == a = Node el left right
| el < a = Node a (treeInsert el left) right
| el > a = Node a left (treeInsert el right)