codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
-- $setup -- >>> import Control.Applicative ((<*>)) -- >>> import Data.List (isInfixOf) -- >>> import Test.QuickCheck -- Level: Easy -- Pointfree: yes -- | mostRepeatedElem -- Returns the element with the longest (consecutive) repetition and the -- repetition number -- If there are tie, the last most repeated element is returned -- It returns error on empty string -- -- Examples: -- -- >>> mostRepeatedElem "hello world!" -- ('l',2) -- -- >>> mostRepeatedElem [1,1,2,2] -- (2,2) -- -- prop> (flip isInfixOf <*> uncurry (flip replicate) . mostRepeatedElem) . getNonEmpty mostRepeatedElem :: Eq a => [a] -> (a,Int) mostRepeatedElem = undefined
Private
[
?
]
Run code
Submit