Proposal reminder: Add functions to get consecutive elements to Data.List

Henning Thielemann lemming at henning-thielemann.de
Thu May 19 07:15:11 UTC 2016


On Thu, 19 May 2016, David Feuer wrote:

> You promised a collection of use cases. I seem to have missed it. Could you send the link again?


I found the following uses in my libraries:

* mapAdjacent subtract
     differences between consecutive elements, inverse of cumulative sum (scanl (+) 0)

* and . mapAdjacent (==)
     check whether all elements in a list are equal

* and . mapAdjacent (<=)
     check whether elements are sorted

* mapAdjacent (/=) . map signum
     find zero crossings

* head . dropWhile (uncurry (/=)) . mapAdjacent (,)
     drop until convergence

* mapAdjacent (\x y -> (snd x, fst y))
     turn list of intervals into list of gaps

* mapAdjacent (,)
     collect state transitions for a Hidden Markov model

* product . mapAdjacent binomial . scanr1 (+)
     compute multinomial coefficient


More information about the Libraries mailing list