May we change this to updateAt : Int -> (a -> a) -> List a -> List a?
The same remark applies to setAt and swapAt.
These functions could return the original list when the index is invalid.
What do you think about it? Shall I send a pull-request in that direction?
Use case:
numbers = [14, 42, 99]
numbers |> updateIfIndex ((==) 0) (\n -> n + 1)
-- should be the same than
numbers |> updateAt 0 (\n -> n + 1)
-- but with current we have to do:
numbers |> updateAt 0 (\n -> n + 1) |> Maybe.withDefault numbers
Several functions like
removeAt : Int -> List a -> List a
orupdateIfIndex : (Int -> Bool) -> (a -> a) -> List a -> List a
return aList a
and that's fine (from my point of view)!On the other hand,
updateAt : Int -> (a -> a) -> List a -> Maybe (List a)
returns aMaybe (List a)
which is annoying.May we change this to
updateAt : Int -> (a -> a) -> List a -> List a
?The same remark applies to
setAt
andswapAt
.These functions could return the original list when the index is invalid.
What do you think about it? Shall I send a pull-request in that direction?
Use case: