Erl.Data.List
- Package
- erl-lists
- Repository
- purerl/purescript-erl-lists
#toUnfoldable Source
toUnfoldable :: forall a f. Unfoldable f => List a -> f aConvert a list into any unfoldable structure.
Running time: O(n)
#fromFoldable Source
fromFoldable :: forall a f. Foldable f => f a -> List aConstruct 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 IntFind the index of the last element equal to the specified element.
#findLastIndex Source
findLastIndex :: forall a. (a -> Boolean) -> List a -> Maybe IntFind 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 aDelete 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 aCalculate the intersection of two lists, using the specified function to determine equality of elements.
Running time: O(n^2)
#zipWith Source
zipWith :: forall c b a. (a -> b -> c) -> List a -> List b -> List cApply 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 c b a m. 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 b a. Filterable f => (a -> Maybe b) -> f a -> f bRe-exports from Data.FunctorWithIndex
#mapWithIndex Source
mapWithIndex :: forall i f b a. FunctorWithIndex i f => (i -> a -> b) -> f a -> f bRe-exports from Erl.Data.List.Types
#NonEmptyList Source
newtype NonEmptyList aConstructors
NonEmptyList (NonEmpty List a)
Instances
Newtype (NonEmptyList a) _(Eq a) => Eq (NonEmptyList a)(Ord a) => Ord (NonEmptyList a)(Show a) => Show (NonEmptyList a)Functor NonEmptyListApply NonEmptyListApplicative NonEmptyListBind NonEmptyListMonad NonEmptyListAlt NonEmptyListExtend NonEmptyListComonad NonEmptyListSemigroup (NonEmptyList a)Foldable NonEmptyListTraversable NonEmptyListFoldable1 NonEmptyListUnfoldable1 NonEmptyListFunctorWithIndex Int NonEmptyListFoldableWithIndex Int NonEmptyListTraversableWithIndex Int NonEmptyListTraversable1 NonEmptyList
#List Source
data List :: Type -> TypeInstances
(Show a) => Show (List a)(Eq a) => Eq (List a)Eq1 List(Ord a) => Ord (List a)Ord1 ListSemigroup (List a)Monoid (List a)Functor ListFoldable ListUnfoldable1 ListUnfoldable ListTraversable ListTraversableWithIndex Int ListFoldableWithIndex Int ListFunctorWithIndex Int ListApply ListApplicative ListBind ListMonad ListAlt ListPlus ListAlternative ListMonadZero ListMonadPlus ListCompactable ListFilterable ListWitherable List