Skip to content

Instantly share code, notes, and snippets.

@sparksp
Created December 19, 2019 19:47
Show Gist options
  • Save sparksp/05b47b48d768ff2108804bd153903464 to your computer and use it in GitHub Desktop.
Save sparksp/05b47b48d768ff2108804bd153903464 to your computer and use it in GitHub Desktop.
Remove an item from an Array by index
{-| 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