Module

Data.Array.Extra.All

Package
purescript-arrays-extra
Repository
flip111/purescript-arrays-extra

#findIndices Source

findIndices :: forall a. (a -> Boolean) -> Array a -> Array Int

Find the all the indices for which a predicate holds.

findIndices (contains $ Pattern "b") ["a", "bb", "b", "d"] = [1, 2]
findIndices (contains $ Pattern "x") ["a", "bb", "b", "d"] = []

#updateAllWith Source

updateAllWith :: forall a. (a -> Boolean) -> a -> Array a -> Array a

Find all elements matching a predicate and replace them with another element.

updateAllWith odd 4 [1,2,3] == Just [4,2,4]

#updateAllArrayWith Source

updateAllArrayWith :: forall a. Partial => (a -> Boolean) -> Array a -> Array a -> Array a

Find an element by a predicate and return an array with the element replaced by an array.

updateAllArrayWith odd [21,22] [1,2,3,4,5] == Just [21,22,2,21,22,4,21,22]

#modifyAllWith Source

modifyAllWith :: forall a. (a -> Boolean) -> (a -> a) -> Array a -> Array a

Find all elements matching a predicate and modify each element found.

modifyAllWith odd (* 3) [1,2,3] == Just [3,2,9]