Advertisement
Guest User

Untitled

a guest
May 25th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import Data.ByteString.Lazy.Char8 as BS
  2. import Data.Word
  3. import Data.Bits
  4. import Data.List
  5. import Data.Char
  6. import Data.List.Split
  7.  
  8. isChar x = o > 31 && o < 127 where o = ord x
  9.  
  10. scan::[Char]->[Char]->[Char]
  11.  
  12. scan (x:xs) (y1:y2:y3:_) = if isChar x then [y1]++scan xs [y2,y3,x] else [y1,y2,y3,'\n']++scan xs []
  13. scan (x:xs) (y1:y2:_) = if isChar x then scan xs [y1,y2,x] else scan xs []
  14. scan (x:xs) (y1:_) = if isChar x then scan xs [y1,x] else scan xs []
  15. scan (x:xs) [] = if isChar x then scan xs [x] else scan xs []
  16. scan [] (y1:y2:y3:_) = [y1,y2,y3]
  17. scan [] _ = []
  18.  
  19. main = do
  20. contents <- BS.readFile "inp"
  21. let foundStr = scan (unpack contents) []
  22. Prelude.writeFile "out.txt" foundStr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement