elm-community / array-extra

convenience functions for working with Array

Home Page:http://package.elm-lang.org/packages/elm-community/array-extra/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Array.insert

AlienKevin opened this issue · comments

Insert an element to an array at a specific index (can be negative).

insert : Int -> a -> Array a -> Array a
insert i el arr =
  Array.append
  ( Array.push el <|
    Array.slice 0 i arr
  )
  (Array.slice i (Array.length arr) arr)

Check out sample tests on Ellie

I saw the insertAt pull request so I'm closing this issue. Could someone publish the new version with insertAt though?

@prikhi Would you be able to create a new release with this feature?

Sure, happy to help.

New release pushed.