Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

99 Elm Problems/Problem 10

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Run-length encode a list of tuples. Output runs of equal elements as tuples (n, e) where n is the number of duplicates of the element e. import Html exposing (text) import List runLengthEncode : List a -> List (a, Int) -- your implementation goes here main = text <| toString <| runLengthEncode [1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 6, 6] Result: [ ( 1, 3 ), ( 2, 1 ), ( 3, 3 ), ( 4, 4 ), ( 5, 1 ), ( 6, 2 ) ] Solutions