Haskell: The challenge

I’ve come up with a definitive version for the programming challenge for Haskell. It is as follows:

Write an LC_RLE1 decompressor. If that works out, attempt to write an LC_LZ2 decompressor. The keyword is “attempt” as I’m pretty sure I won’t be able to finish it in time due to the difficulty. I do have a rough idea of how to attempt the latter though:

Write a function for each command. In pseudo code, it would roughly look something like this:

byte[] directCopy(byte[] input, int length)
byte[] directFill(byte data, int length)
byte[] wordFill(uint16 word, int length)
byte[] increasingFill(byte data, int length)
byte[] repeat(uint16 index, int length)

And then somehow put them together as one big “decompressLZ2” command. As for LC_RLE1 I suppose it’s just the first two functions.

The idea is that I work my way up from a simple format to a more complex format. LZ2 is quite complex though and it’s possible that I might actually get stuck solely due to my inexperience with Haskell rather than the format itself.

The biggest challenge would probably be reading out the individual bits out of a byte, as well as loading/saving a file in Haskell (it might sound trivial but I have absolutely no clue how this is done).

I presented my idea to the instructor and got his approval. Hopefully, I can finish at least the RLE1 challenge tomorrow already as I’m quite short on time.

Leave a Reply

Your email address will not be published. Required fields are marked *