Created
December 19, 2019 19:47
-
-
Save sparksp/05b47b48d768ff2108804bd153903464 to your computer and use it in GitHub Desktop.
Remove an item from an Array by index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| Remove the indexed item from the Array | |
Array.fromList [1, 2, 3, 4] | |
|> arrayRemove 2 | |
== Array.fromList [1, 2, 4] | |
-} | |
arrayRemove : Int -> Array a -> Array a | |
arrayRemove index array = | |
Array.append | |
(Array.slice 0 index array) | |
(Array.slice (index + 1) (Array.length array) array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment