Advertisement
Guest User

Prefix compression (secondo tentativo)

a guest
Oct 5th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main = do
  2.   sa <- getLine
  3.   sb <- getLine
  4.   let output = prefixCompression [] sa sb
  5.   map anteponiLunghezza output
  6.   print output
  7.  
  8. prefixCompression p sa sb
  9.     | null sa = [p, "", sb]
  10.     | null sb = [p, sa, ""]
  11.     | (head sa == head sb) = prefixCompression (p ++ [head sa] ) (tail sa) (tail sb)
  12.     | otherwise          = [p, sa, sb]
  13.  
  14. anteponiLunghezza s =
  15.   show (length s) ++ " " ++ s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement