daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. wrap_print :: Show a => Rope a -> IO ()
  2. wrap_print rope = putStrLn "strict graph G {" >> printer 1 (Just rope) >> putStrLn "}"
  3.  
  4. printer :: Show a =>  Int -> Maybe ( Rope a ) -> IO ()
  5. printer index rope = case rope of (Just (Node weight left right)) -> putStr ( (show index) ++ "\n" ++ (show index) ++ " [label="++ "\"" ++ (show weight) ++ "\""  ++ "];" ++ "\n"  ) >>                                                      
  6.                                                                             putStr ((show index) ++ " -- " )>>
  7.                                                                             printer (index*2 + 1) left >>
  8.                                                                             putStr ((show index) ++ " -- " ) >>
  9.                                                                             printer (index*2) right
  10.                                   (Just (Leaf weight value)) -> putStr ((show index) ++ "\n" ++ (show index) ++  " [label=" ++ "\"" ++ (show value) ++ "\"" ++ ",shape=diamond, color = red];" ++ "\n")                                      
  11.                                   Nothing -> putStr ((show index) ++ "\n" ++ (show index) ++  " [label=" ++ "\"Nothing\"" ++ ",shape=diamond, color = red];" ++ "\n")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top