Skip to content

Commit 9b981c3

Browse files
Merge pull request #169 from milesfrain/patch-1
Fix lazy list docs where original is returned instead of nothing
2 parents 7f41745 + 6747c90 commit 9b981c3

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

src/Data/List/Lazy.purs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,8 @@ findIndex fn = go 0
326326
findLastIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int
327327
findLastIndex fn xs = ((length xs - 1) - _) <$> findIndex fn (reverse xs)
328328

329-
-- | Insert an element into a list at the specified index, returning a new
330-
-- | list or `Nothing` if the index is out-of-bounds.
331-
-- |
332-
-- | This function differs from the strict equivalent in that out-of-bounds arguments
333-
-- | result in the element being appended at the _end_ of the list.
329+
-- | Insert an element into a list at the specified index, or append the element
330+
-- | to the end of the list if the index is out-of-bounds, returning a new list.
334331
-- |
335332
-- | Running time: `O(n)`
336333
insertAt :: forall a. Int -> a -> List a -> List a
@@ -340,11 +337,8 @@ insertAt n x xs = List (go <$> unwrap xs)
340337
go Nil = Cons x nil
341338
go (Cons y ys) = Cons y (insertAt (n - 1) x ys)
342339

343-
-- | Delete an element from a list at the specified index, returning a new
344-
-- | list or `Nothing` if the index is out-of-bounds.
345-
-- |
346-
-- | This function differs from the strict equivalent in that out-of-bounds arguments
347-
-- | result in the original list being returned unchanged.
340+
-- | Delete an element from a list at the specified index, returning a new list,
341+
-- | or return the original list unchanged if the index is out-of-bounds.
348342
-- |
349343
-- | Running time: `O(n)`
350344
deleteAt :: forall a. Int -> List a -> List a
@@ -354,11 +348,8 @@ deleteAt n xs = List (go n <$> unwrap xs)
354348
go 0 (Cons y ys) = step ys
355349
go n' (Cons y ys) = Cons y (deleteAt (n' - 1) ys)
356350

357-
-- | Update the element at the specified index, returning a new
358-
-- | list or `Nothing` if the index is out-of-bounds.
359-
-- |
360-
-- | This function differs from the strict equivalent in that out-of-bounds arguments
361-
-- | result in the original list being returned unchanged.
351+
-- | Update the element at the specified index, returning a new list,
352+
-- | or return the original list unchanged if the index is out-of-bounds.
362353
-- |
363354
-- | Running time: `O(n)`
364355
updateAt :: forall a. Int -> a -> List a -> List a
@@ -369,22 +360,16 @@ updateAt n x xs = List (go n <$> unwrap xs)
369360
go n' (Cons y ys) = Cons y (updateAt (n' - 1) x ys)
370361

371362
-- | Update the element at the specified index by applying a function to
372-
-- | the current value, returning a new list or `Nothing` if the index is
373-
-- | out-of-bounds.
374-
-- |
375-
-- | This function differs from the strict equivalent in that out-of-bounds arguments
376-
-- | result in the original list being returned unchanged.
363+
-- | the current value, returning a new list, or return the original list unchanged
364+
-- | if the index is out-of-bounds.
377365
-- |
378366
-- | Running time: `O(n)`
379367
modifyAt :: forall a. Int -> (a -> a) -> List a -> List a
380368
modifyAt n f = alterAt n (Just <<< f)
381369

382370
-- | Update or delete the element at the specified index by applying a
383-
-- | function to the current value, returning a new list or `Nothing` if the
384-
-- | index is out-of-bounds.
385-
-- |
386-
-- | This function differs from the strict equivalent in that out-of-bounds arguments
387-
-- | result in the original list being returned unchanged.
371+
-- | function to the current value, returning a new list, or return the
372+
-- | original list unchanged if the index is out-of-bounds.
388373
-- |
389374
-- | Running time: `O(n)`
390375
alterAt :: forall a. Int -> (a -> Maybe a) -> List a -> List a

0 commit comments

Comments
 (0)