< 99 Elm Problems
Repeat each element of a list a given number of times.
import Html exposing (text)
import List
repeatElements : Int -> List a -> List a
-- your implementation goes here
main =
text <| toString <|
repeatElements 3 [1, 2, 3, 3]
Result:
[1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3]
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.