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]

#deleteWith Source

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

Find an element by a predicate and return an array without that element when it was found.

deleteWith (_ == 2) [2,1,3,2] == Just [1,3]

#difference Source

difference :: forall a. Eq a => Array a -> Array a -> Array a

Like difference in Data.Array but removes all of the elements from the first array which have a match in the second array.

difference [2, 1, 2] [2, 3] == [1,2] -- Data.Array
difference [2, 1, 2] [2, 3] == [1]   -- Data.Array.Extra.All