| Copyright | Copyright (C) 2021 Yoo Chung |
|---|---|
| License | GPL-3.0-or-later |
| Maintainer | dev@chungyc.org |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Problems.P13
Description
Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P13.
Synopsis
- encodeDirect :: Eq a => [a] -> [Encoding a]
Documentation
encodeDirect :: Eq a => [a] -> [Encoding a] Source #
Implement the so-called run-length encoding data compression method directly.
I.e., do not explicitly create the sublists containing the duplicates,
as with pack, but only count them.
As with encodeModified,
simplify the result list by replacing the singletons ( by Multiple 1 x)(.Single x)
Examples
>>>encodeDirect "aaaabccaadeeee"[Multiple 4 'a',Single 'b',Multiple 2 'c',Multiple 2 'a',Single 'd',Multiple 4 'e']