Skip to content

Instantly share code, notes, and snippets.

@laser
Created March 25, 2014 21:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save laser/9772036 to your computer and use it in GitHub Desktop.
insert :: LogMessage -> MessageTree -> MessageTree
insert (Unknown _) t = t
insert m@(LogMessage _ ts1 _) t = case t of
(Leaf) -> Node Leaf m Leaf
(Node _ (Unknown _) _) -> t
(Node t1 m2@(LogMessage _ ts2 _) t2) -> case ts1 < ts2 of
True -> Node (insert m t1) m2 t2
False -> Node t1 m2 (insert m t2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment