Push final

This commit is contained in:
WickedJack99
2024-01-21 17:42:00 +01:00
parent fb6935996b
commit f9ecc5fb22
43 changed files with 37 additions and 23 deletions

View File

@@ -5,7 +5,7 @@
? /home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/.stack-work/dist/x86_64-linux/ghc-9.4.7/build/huffman-exe/autogen/cabal_macros.h
: hash: 5c589f29d12e441a25182925543712cdca33bb844ebce29bafe987697bb2b9b1
/home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/exe/Main.hs:
hash: bc321c5e6dea106198eca53ccb8e31b17746ac198c7de206483c2989e73b1fd0
hash: cf1567e91a414e222d1367991772f86ee6c1e99c676b68448f0fa6cb0d72c644
/home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/huffman.cabal:
hash: 0f828acaf94c12587e96d013bb3f48a4c4abac1e2efe6cce31dbffe48864d1f2
/home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/package.yaml:

View File

@@ -11,6 +11,6 @@
/home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/src/Auxiliaries.hs:
hash: 5a404af397ad51d6d268ac0a318157dd9511d113c3fbfce35cc238d42974425f
/home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/src/Huffman.hs:
hash: c379eba92ecb90bbd210add96734d89b196535d973d68cbdb8f9c7195284211f
hash: fcfb7f6cab0bc26c8b2258916aa5caa36930d88be23b19270856417be6e93942
/usr/include/stdc-predef.h:
hash: d6bcc58441a423bbb3a52171fcd3b84d8b36e332a55221a1c3e6e899bc43ccb3

View File

@@ -9,6 +9,6 @@
/home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/package.yaml:
hash: e9fcddf7857388c0e51188152e25a1d446e2e46628ed45552bdc3b635472171c
/home/a/Documents/Repositories/Anwendungsentwicklung_Haskell/Aufgabe_6/code/test/Tests.hs:
hash: d146588effdec1312dbcdc1609a1293ad40f1b8f14cea6b19181cbfa13e499cc
hash: 95a1810395f150adb8f70b92eed6390ce6624481a185ab1b481856e22a1e1400
/usr/include/stdc-predef.h:
hash: d6bcc58441a423bbb3a52171fcd3b84d8b36e332a55221a1c3e6e899bc43ccb3

Binary file not shown.

View File

@@ -1,9 +0,0 @@
Aaron Adrian
Aaron Adrian
Aaron Adrian
Aaron Adrian
Aaron Adrian
Aaron Adrian
Aaron Adrian
Aaron Adrian
Aaron Adrian

View File

@@ -1,6 +1,12 @@
module Main where
-- import Huffman
import System.Environment ( getArgs )
import Data.List (isSuffixOf)
import Huffman
main :: IO ()
main = pure ()
main = do
[input,output] <- getArgs
if ".comp" `isSuffixOf` output
then encodeFile input output
else decodeFile input output

Binary file not shown.

View File

@@ -5,7 +5,7 @@ import Auxiliaries ( Bit (..), FileContent (FileContent, fc_codingTable, fc_cont
import Data.Maybe (fromMaybe)
import Data.Char (toUpper)
import qualified Data.IntMap.Strict as IntMap
import System.IO
import System.IO ( hGetContents, hPutStr, withFile, IOMode(WriteMode, ReadMode) )
type IntMap = IntMap.IntMap
type Map = Map.Map
@@ -237,15 +237,15 @@ treeAAABC = Root (Inner (Inner (Leaf 'C' 1) (Leaf 'B' 1) 2) (Leaf 'A' 3) 5)
-----------------------------------------------------------------------
toDecodeTree :: CodingTable -> HTree
toDecodeTree table = foldl1 mergeTrees $ map (uncurry partTree) (Map.toList table)
toDecodeTree table = foldl1 mergeTrees (map (\(char, bitCode) -> partTree char bitCode) (Map.toList table))
partTree :: Char -> [Bit] -> HTree
partTree char bits =
case bits of
[] -> Root (Leaf char 0)
(x:rest) ->
let next = partTree char rest in
case x of
(bit:rest) ->
let next = partTree char rest
in case bit of
Zero -> Root (Inner (getNode next) (Leaf 'e' 1) 0)
One -> Root (Inner (Leaf 'e' 1) (getNode next) 0)
@@ -291,4 +291,14 @@ decodeFile input output = do
in do withFile output WriteMode (\handle -> do hPutStr handle decodedString)
bitlistToList :: Bitlist -> [Bit]
bitlistToList (Bitlist bits) = bits
bitlistToList (Bitlist bits) = bits
-----------------------------------------------------------------------
-- Aufgabe 9
-----------------------------------------------------------------------
-- siehe Tests.hs
-----------------------------------------------------------------------
-- Aufgabe 10
-----------------------------------------------------------------------
-- siehe Main.hs

1
Aufgabe_6/code/test.txt Normal file
View File

@@ -0,0 +1 @@
Test text for excercise 9.

View File

@@ -5,6 +5,7 @@ import qualified Data.Map.Strict as Map
import Huffman
import Test.HUnit
import Auxiliaries (Bit (..))
import System.IO ( hGetContents, withFile, IOMode(ReadMode) )
type CodingTable = Map.Map Char [Bit]
@@ -48,9 +49,14 @@ test_toFromWord8 :: IO ()
test_toFromWord8 = pure ()
test_encodeDecodeFile :: IO ()
test_encodeDecodeFile = pure() --do
--_ <- encodeFile "hitchhiker.txt" "hitchhiker.comp"
-- decodeFile "hitchhiker.comp" "hitchhiker2.txt"
test_encodeDecodeFile = do
_ <- encodeFile "test.txt" "test.comp"
_ <- decodeFile "test.comp" "test2.txt"
withFile "test.txt" ReadMode $ \handle -> do
inputContent <- hGetContents handle
withFile "test2.txt" ReadMode $ \handle -> do
outputContent <- hGetContents handle
assertEqual "test encodeDecodeFile" True (inputContent == outputContent)
allTests :: Test
allTests =