, Elm List .
. . , , - . ( , , , , , . , .)
updateListAt :: List a -> Int -> a -> List a
updateListAt (head :: tail) 0 x = x :: tail
updateListAt (head :: tail) i x = head :: (updateListAt tail (i - 1) x)
However, both the runtime and the complexity of the space will be O (n) both on average and in the worst case, regardless of the method used. This is due to the fact that Elm Listis a singly linked list.
Relatively assoc-in, if you look at the source of Clojure, you will see that it is assoc-insimply recursively defined in terms assoc. However, I think you will have trouble entering it for an arbitrary dynamic depth in Elm.
source
share