Commit 50e06162 authored by Ben Gamari's avatar Ben Gamari 🐢

real/compress: Detabify

parent b97b0b2c
......@@ -32,23 +32,23 @@ dec_to_bin' x
codes_to_ascii :: [Int] -> [Int]
codes_to_ascii [] = []
codes_to_ascii (x:y:ns)
= x_div : ((x_rem * 16) + y_div) : y_rem : codes_to_ascii ns
= x_div : ((x_rem * 16) + y_div) : y_rem : codes_to_ascii ns
where
(x_div, x_rem) = divRem x 16
(y_div, y_rem) = divRem y 256
codes_to_ascii [n]
= [x_div , x_rem]
= [x_div , x_rem]
where
(x_div, x_rem) = divRem n 16
ascii_to_codes [] = []
ascii_to_codes (x:y:z:ns)
= (x * 16) + y_div : (y_rem * 256) + z : ascii_to_codes ns
where
(y_div, y_rem) = divRem y 16
= (x * 16) + y_div : (y_rem * 256) + z : ascii_to_codes ns
where
(y_div, y_rem) = divRem y 16
ascii_to_codes [x,y]
= [(x * 16) + y_rem]
where
(y_div, y_rem) = divRem y 16
= [(x * 16) + y_rem]
where
(y_div, y_rem) = divRem y 16
divRem x y = (x `div` y, x `rem` y) -- missing from PreludeCore ?
......@@ -6,7 +6,7 @@ result 0 = []
result n = codes_to_ascii (3077, 1192) ++ result (n-1)
codes_to_ascii (x,y)
= x_div : ((x_rem * 16) + y_div) : [y_rem]
= x_div : ((x_rem * 16) + y_div) : [y_rem]
where
(x_div, x_rem) = divRem x 16
(y_div, y_rem) = divRem y 256
......
......@@ -21,7 +21,7 @@
module Decode (decode)
where
import Prelude hiding( lookup ) -- lookup defined locally
import Prelude hiding( lookup ) -- lookup defined locally
import Defaults
import BinConv
......
......@@ -108,8 +108,8 @@ lzw_code_file [] code_table next_code = [];
lzw_code_file input code_table next_code
= -- partain: case-ified lazy where
case (code_string input ILIT(0) next_code code_table) of {
_TRIP_(input2,n,code_table2) ->
IBOX(n) : lzw_code_file input2 code_table2 (next_code _ADD_ ILIT(1))
_TRIP_(input2,n,code_table2) ->
IBOX(n) : lzw_code_file input2 code_table2 (next_code _ADD_ ILIT(1))
};
code_string :: [Char] -> FAST_INT -> FAST_INT -> PrefixTree -> FAST_TRIPLE;
......@@ -163,7 +163,7 @@ integer_list_to_char_list [] = [];
integer_list_to_char_list2 (IBOX(c) : l) n
= CBOX(_CHR_ ((n _MUL_ ILIT(16)) _ADD_ ((c _QUOT_ ILIT(256)) _REM_ ILIT(16))))
: CBOX(_CHR_ c)
: CBOX(_CHR_ c)
: integer_list_to_char_list l;
integer_list_to_char_list2 [] n = CBOX(_CHR_ (n _MUL_ ILIT(16))) : [];
......
-- Lzw2.hs looks like an earlier version of Lzw.hs
-- Lzw2.hs looks like an earlier version of Lzw.hs
module Main (main){-export list added by partain-} where {
......@@ -72,8 +72,8 @@ lzw_code_file [] code_table next_code = [];
lzw_code_file input code_table next_code
= -- partain: case-ified lazy where
case (code_string ILIT(0) next_code input code_table) of {
_TRIP_(input2,n,code_table2) ->
IBOX(n) : lzw_code_file input2 code_table2 (next_code _ADD_ ILIT(1))
_TRIP_(input2,n,code_table2) ->
IBOX(n) : lzw_code_file input2 code_table2 (next_code _ADD_ ILIT(1))
};
code_string :: FAST_INT -> FAST_INT -> [Char] -> PrefixTree -> FAST_TRIPLE;
......@@ -105,7 +105,7 @@ integer_list_to_char_list [] = [];
integer_list_to_char_list2 (IBOX(c) : l) n
= CBOX(_CHR_ ((n _MUL_ ILIT(16)) _ADD_ ((c _QUOT_ ILIT(256)) _REM_ ILIT(16))))
: CBOX(_CHR_ c)
: CBOX(_CHR_ c)
: integer_list_to_char_list l;
integer_list_to_char_list2 [] n = CBOX(_CHR_ (n _MUL_ ILIT(16))) : [];
......
......@@ -14,7 +14,7 @@
module Main (main) where
import Defaults
import BinConv -- binary conversion routines
import BinConv -- binary conversion routines
import Encode -- coding routine
import Control.Monad
import System.IO
......
......@@ -10,8 +10,8 @@ data PrefixElem a b = PTE a b (PrefixTree a b)
{-partain-}
insert k v PTNil =
PT (PTE k v PTNil) PTNil PTNil
PT (PTE k v PTNil) PTNil PTNil
insert k v (PT p@(PTE k' v' t) l r)
| k < k' = PT p (insert k v l) r
| k < k' = PT p (insert k v l) r
| k > k' = PT p l (insert k v r)
| otherwise = PT p l r
......@@ -13,11 +13,11 @@
module Uncompress (main) where
import Defaults
import BinConv -- binary conversion routines
import BinConv -- binary conversion routines
import Decode -- decoding routines
main = getContents >>= \ inp ->
putStr (uncompress inp)
putStr (uncompress inp)
{- To uncompress a string we first convert the characters to n-bit binaries
- and then to decimals which can then be decoded.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment