Alias for concatNel
Alias for concatNel
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3) scala> nel ::: NonEmptyList.of(4, 5) res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4, 5)
Builds a new List
by applying a partial function to
all the elements from this NonEmptyList
on which the function is defined
Builds a new List
by applying a partial function to
all the elements from this NonEmptyList
on which the function is defined
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5) scala> nel.collect { case v if v < 3 => v } res0: scala.collection.immutable.List[Int] = List(1, 2) scala> nel.collect { | case v if v % 2 == 0 => "even" | case _ => "odd" | } res1: scala.collection.immutable.List[String] = List(odd, even, odd, even, odd)
Append another NonEmptyList
Check whether at least one element satisfies the predicate
Remove elements not matching the predicate
Remove elements not matching the predicate
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5) scala> nel.filter(_ < 3) res0: scala.collection.immutable.List[Int] = List(1, 2)
Remove elements matching the predicate
Remove elements matching the predicate
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5) scala> nel.filterNot(_ < 3) res0: scala.collection.immutable.List[Int] = List(3, 4, 5)
Find the first element matching the predicate, if one exists
Left-associative fold on the structure using f.
Check whether all elements satisfy the predicate
Selects the last element
Selects the last element
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5) scala> nel.last res0: Int = 5
Applies f to all the elements of the structure
The size of this NonEmptyList
The size of this NonEmptyList
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5) scala> nel.size res0: Int = 5
Return the head and tail into a single list
Return the head and tail into a single list
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5) scala> nel.toList res0: scala.collection.immutable.List[Int] = List(1, 2, 3, 4, 5)
Source: https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/data/NonEmptyList.scala
A data type which represents a non empty list of A, with single element (head) and optional structure (tail).