Erl.Data.List
- Package
- erl-lists
- Repository
- purerl/purescript-erl-lists
#toUnfoldable Source
toUnfoldable :: forall f a. Unfoldable f => List a -> f a
Convert a list into any unfoldable structure.
Running time: O(n)
#fromFoldable Source
fromFoldable :: forall f a. Foldable f => f a -> List a
Construct a list from a foldable structure.
Running time: O(n)
#(..) Source
Operator alias for Erl.Data.List.range (non-associative / precedence 8)
An infix synonym for range
.
#(!!) Source
Operator alias for Erl.Data.List.index (left-associative / precedence 8)
An infix synonym for index
.
#elemLastIndex Source
elemLastIndex :: forall a. Eq a => a -> List a -> Maybe Int
Find the index of the last element equal to the specified element.
#findLastIndex Source
findLastIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int
Find the last index for which a predicate holds.
#span Source
span :: forall a. (a -> Boolean) -> List a -> { init :: List a, rest :: List a }
Split a list into two parts:
- the longest initial segment for which all elements satisfy the specified predicate
- the remaining elements
For example,
span (\n -> n % 2 == 1) (1 : 3 : 2 : 4 : 5 : Nil) == { init: (1 : 3 : Nil), rest: (2 : 4 : 5 : Nil) }
Running time: O(n)
#group Source
group :: forall a. Eq a => List a -> List (NonEmptyList a)
Group equal, consecutive elements of a list into lists.
For example,
group (1 : 1 : 2 : 2 : 1 : Nil) == (1 : 1 : Nil) : (2 : 2 : Nil) : (1 : Nil) : Nil
Running time: O(n)
#group' Source
group' :: forall a. Ord a => List a -> List (NonEmptyList a)
Sort and then group the elements of a list into lists.
group' [1,1,2,2,1] == [[1,1,1],[2,2]]
#groupBy Source
groupBy :: forall a. (a -> a -> Boolean) -> List a -> List (NonEmptyList a)
Group equal, consecutive elements of a list into lists, using the specified equivalence relation to determine equality.
Running time: O(n)
#difference Source
difference :: forall a. Eq a => List a -> List a -> List a
Delete the first occurrence of each element in the second list from the first list.
Running time: O(n^2)
#intersectBy Source
intersectBy :: forall a. (a -> a -> Boolean) -> List a -> List a -> List a
Calculate the intersection of two lists, using the specified function to determine equality of elements.
Running time: O(n^2)
#zipWith Source
zipWith :: forall a b c. (a -> b -> c) -> List a -> List b -> List c
Apply a function to pairs of elements at the same positions in two lists, collecting the results in a new list.
If one list is longer, elements will be discarded from the longer list.
For example
zipWith (*) (1 : 2 : 3 : Nil) (4 : 5 : 6 : 7 Nil) == 4 : 10 : 18 : Nil
Running time: O(min(m, n))
#zipWithA Source
zipWithA :: forall m a b c. Applicative m => (a -> b -> m c) -> List a -> List b -> m (List c)
A generalization of zipWith
which accumulates results in some Applicative
functor.
#transpose Source
transpose :: forall a. List (List a) -> List (List a)
The 'transpose' function transposes the rows and columns of its argument. For example,
transpose ((1:2:3:Nil) : (4:5:6:Nil) : Nil) ==
((1:4:Nil) : (2:5:Nil) : (3:6:Nil) : Nil)
If some of the rows are shorter than the following rows, their elements are skipped:
transpose ((10:11:Nil) : (20:Nil) : Nil : (30:31:32:Nil) : Nil) ==
((10:20:30:Nil) : (11:31:Nil) : (32:Nil) : Nil)
Re-exports from Data.Filterable
#filter Source
filter :: forall f a. Filterable f => (a -> Boolean) -> f a -> f a
#filterMap Source
filterMap :: forall f a b. Filterable f => (a -> Maybe b) -> f a -> f b
Re-exports from Data.FunctorWithIndex
#mapWithIndex Source
mapWithIndex :: forall f i a b. FunctorWithIndex i f => (i -> a -> b) -> f a -> f b
Re-exports from Erl.Data.List.Types
#NonEmptyList Source
newtype NonEmptyList a
Constructors
NonEmptyList (NonEmpty List a)
Instances
Newtype (NonEmptyList a) _
(Eq a) => Eq (NonEmptyList a)
(Ord a) => Ord (NonEmptyList a)
(Show a) => Show (NonEmptyList a)
Functor NonEmptyList
Apply NonEmptyList
Applicative NonEmptyList
Bind NonEmptyList
Monad NonEmptyList
Alt NonEmptyList
Extend NonEmptyList
Comonad NonEmptyList
Semigroup (NonEmptyList a)
Foldable NonEmptyList
Traversable NonEmptyList
Foldable1 NonEmptyList
Unfoldable1 NonEmptyList
FunctorWithIndex Int NonEmptyList
FoldableWithIndex Int NonEmptyList
TraversableWithIndex Int NonEmptyList
Traversable1 NonEmptyList
#List Source
data List :: Type -> Type
Instances
(Show a) => Show (List a)
(Eq a) => Eq (List a)
Eq1 List
(Ord a) => Ord (List a)
Ord1 List
Semigroup (List a)
Monoid (List a)
Functor List
Foldable List
Unfoldable1 List
Unfoldable List
Traversable List
TraversableWithIndex Int List
FoldableWithIndex Int List
FunctorWithIndex Int List
Apply List
Applicative List
Bind List
Monad List
Alt List
Plus List
Alternative List
MonadPlus List
Compactable List
Filterable List
Witherable List