ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Problems.P12

Description

Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P12.

Synopsis

Documentation

decodeModified :: [Encoding a] -> [a] Source #

Given a run-length code list generated by encodeModified, construct its uncompressed version.

Examples

>>> decodeModified [Multiple 4 'a',Single 'b',Multiple 2 'c',Multiple 2 'a',Single 'd',Multiple 4 'e']
"aaaabccaadeeee"

data Encoding a Source #

Encodes one or more consecutively duplicate elements.

Constructors

Single a

Represents a single occurrence of an element.

Multiple Int a

Represents an element repeating consecutively a given number of times.

Instances

Instances details
Generic (Encoding a) Source # 
Instance details

Defined in Problems.Lists

Associated Types

type Rep (Encoding a) :: Type -> Type #

Methods

from :: Encoding a -> Rep (Encoding a) x #

to :: Rep (Encoding a) x -> Encoding a #

Show a => Show (Encoding a) Source # 
Instance details

Defined in Problems.Lists

Methods

showsPrec :: Int -> Encoding a -> ShowS #

show :: Encoding a -> String #

showList :: [Encoding a] -> ShowS #

NFData a => NFData (Encoding a) Source # 
Instance details

Defined in Problems.Lists

Methods

rnf :: Encoding a -> () #

Eq a => Eq (Encoding a) Source # 
Instance details

Defined in Problems.Lists

Methods

(==) :: Encoding a -> Encoding a -> Bool #

(/=) :: Encoding a -> Encoding a -> Bool #

type Rep (Encoding a) Source # 
Instance details

Defined in Problems.Lists