Copyright | Copyright (C) 2021 Yoo Chung |
---|---|

License | GPL-3.0-or-later |

Maintainer | dev@chungyc.org |

Safe Haskell | Safe-Inferred |

Language | GHC2021 |

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

# Documentation

encode :: Eq a => [a] -> [(Int, a)] Source #

Use the `pack`

function to implement
the so-called run-length encoding data compression method.

Consecutive duplicates of elements are encoded as tuples `(n, e)`

,
where `n`

is the number of duplicates of the element `e`

.

### Examples

`>>>`

[(4,'a'),(1,'b'),(2,'c'),(2,'a'),(1,'d'),(4,'e')]`encode "aaaabccaadeeee"`