99 個 Elm 問題/問題 15
外觀
重複給定列表的每個元素指定次數。
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]
結果
[1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3]