sewardj | a24827f | 2005-01-20 17:57:55 +0000 | [diff] [blame] | 1 | |
| 2 | module Main where |
| 3 | |
| 4 | main |
sewardj | 807598d | 2005-01-31 18:54:23 +0000 | [diff] [blame] | 5 | = do x1 <- readFile "test2.sorted" |
sewardj | a24827f | 2005-01-20 17:57:55 +0000 | [diff] [blame] | 6 | let x2 = lines x1 |
| 7 | x3 = zip [1 ..] x2 |
| 8 | x4 = concat (map qq x3) |
| 9 | --putStr x4 |
sewardj | 807598d | 2005-01-31 18:54:23 +0000 | [diff] [blame] | 10 | writeFile "test2.orig" x4 |
sewardj | a24827f | 2005-01-20 17:57:55 +0000 | [diff] [blame] | 11 | |
| 12 | |
| 13 | qq :: (Int, String) -> String |
| 14 | qq (n, s0) |
| 15 | = let ws = words s0 |
| 16 | bytes = head ws |
| 17 | rest = unwords (tail ws) |
| 18 | bytes2 = foo bytes |
| 19 | in |
| 20 | unlines [ |
| 21 | "", |
| 22 | rest, |
| 23 | ". " ++ show n ++ " 0x12345678 " ++ show (1 + (length bytes `div` 2)), |
| 24 | ". " ++ bytes2 ++ "C3" |
| 25 | ] |
| 26 | |
| 27 | |
| 28 | foo [] = [] |
| 29 | foo (x:y:rest) = x:y:' ':foo rest |