99 個 Elm 問題/第 14 個問題
外觀
複製列表中的每個元素。
import Html exposing (text)
import List
duplicate : List a -> List a
-- your implementation goes here
main =
text <| toString <|
duplicate [1, 2, 3, 5, 8, 8]
結果
[1, 1, 2, 2, 3, 3, 5, 5, 8, 8, 8, 8]
複製列表中的每個元素。
import Html exposing (text)
import List
duplicate : List a -> List a
-- your implementation goes here
main =
text <| toString <|
duplicate [1, 2, 3, 5, 8, 8]
結果
[1, 1, 2, 2, 3, 3, 5, 5, 8, 8, 8, 8]