Skip to content

Instantly share code, notes, and snippets.

@laser
Created March 25, 2014 21:44
Show Gist options
  • Save laser/9772036 to your computer and use it in GitHub Desktop.
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