purescript-lists icon indicating copy to clipboard operation
purescript-lists copied to clipboard

Add Data.List.NonEmpty.deleteAt

Open jamesdbrock opened this issue 5 years ago • 4 comments

https://pursuit.purescript.org/packages/purescript-lists/5.4.1/docs/Data.List.NonEmpty

Data.List.NonEmpty.deleteAt function doesn't exist, but

do exist. Seems like we should add Data.List.NonEmpty.deleteAt ?

jamesdbrock avatar Apr 07 '20 08:04 jamesdbrock

deleteAt :: forall a. Int -> NonEmptyList a -> Maybe (List a)

jamesdbrock avatar Apr 07 '20 09:04 jamesdbrock

deleteAt :: forall a. Int -> NonEmptyList a -> Maybe (List a)
deleteAt i (NonEmptyList (x :| xs))
  | i == 0 = Just xs
  | otherwise = L.Cons x <$> L.deleteAt (i - 1) xs

jamesdbrock avatar Apr 07 '20 09:04 jamesdbrock

Also alterAt?

jamesdbrock avatar Apr 07 '20 09:04 jamesdbrock

Adding these sounds good to me!

garyb avatar Apr 08 '20 14:04 garyb