Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wrap_print :: Show a => Rope a -> IO ()
- wrap_print rope = putStrLn "strict graph G {" >> printer 1 (Just rope) >> putStrLn "}"
- printer :: Show a => Int -> Maybe ( Rope a ) -> IO ()
- printer index rope = case rope of (Just (Node weight left right)) -> putStr ( (show index) ++ "\n" ++ (show index) ++ " [label="++ "\"" ++ (show weight) ++ "\"" ++ "];" ++ "\n" ) >>
- putStr ((show index) ++ " -- " )>>
- printer (index*2 + 1) left >>
- putStr ((show index) ++ " -- " ) >>
- printer (index*2) right
- (Just (Leaf weight value)) -> putStr ((show index) ++ "\n" ++ (show index) ++ " [label=" ++ "\"" ++ (show value) ++ "\"" ++ ",shape=diamond, color = red];" ++ "\n")
- Nothing -> putStr ((show index) ++ "\n" ++ (show index) ++ " [label=" ++ "\"Nothing\"" ++ ",shape=diamond, color = red];" ++ "\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement