99 Elm 問題/問題 21
外觀
在列表中插入一個元素到指定位置。
import Html exposing (text)
import List
insertAt : Int -> a -> List a -> List a
-- your implementation goes here
main =
text <| toString <|
insertAt 2 42 [1..4]
結果
[1, 42, 2, 3, 4]
在列表中插入一個元素到指定位置。
import Html exposing (text)
import List
insertAt : Int -> a -> List a -> List a
-- your implementation goes here
main =
text <| toString <|
insertAt 2 42 [1..4]
結果
[1, 42, 2, 3, 4]