final case class NonEmptyList[+A](head: A, tail: List[A]) extends Product with Serializable
A data type which represents a non empty list of A, with single element (head) and optional structure (tail).
- Alphabetic
- By Inheritance
- NonEmptyList
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new NonEmptyList(head: A, tail: List[A])
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def ++[AA >: A](l: List[AA]): NonEmptyList[AA]
-
def
:+[AA >: A](a: AA): NonEmptyList[AA]
Alias for append
Alias for append
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3) scala> nel :+ 4 res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4)
- def ::[AA >: A](a: AA): NonEmptyList[AA]
-
def
:::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA]
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)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def ===[AA >: A](o: NonEmptyList[AA])(implicit AA: Eq[AA]): Boolean
- def append[AA >: A](a: AA): NonEmptyList[AA]
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def coflatMap[B](f: (NonEmptyList[A]) ⇒ B): NonEmptyList[B]
-
def
collect[B](pf: PartialFunction[A, B]): List[B]
Builds a new
List
by applying a partial function to all the elements from thisNonEmptyList
on which the function is definedBuilds a new
List
by applying a partial function to all the elements from thisNonEmptyList
on which the function is definedscala> 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)
- def concat[AA >: A](other: List[AA]): NonEmptyList[AA]
-
def
concatNel[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA]
Append another NonEmptyList
-
def
distinct[AA >: A](implicit O: Order[AA]): NonEmptyList[AA]
Remove duplicates.
Remove duplicates. Duplicates are checked using
Order[_]
instance. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
exists(p: (A) ⇒ Boolean): Boolean
Check whether at least one element satisfies the predicate
-
def
filter(p: (A) ⇒ Boolean): List[A]
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)
-
def
filterNot(p: (A) ⇒ Boolean): List[A]
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)
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
find(p: (A) ⇒ Boolean): Option[A]
Find the first element matching the predicate, if one exists
- def flatMap[B](f: (A) ⇒ NonEmptyList[B]): NonEmptyList[B]
-
def
foldLeft[B](b: B)(f: (B, A) ⇒ B): B
Left-associative fold on the structure using f.
-
def
foldRight[B](lb: Eval[B])(f: (A, Eval[B]) ⇒ Eval[B]): Eval[B]
Right-associative fold on the structure using f.
-
def
forall(p: (A) ⇒ Boolean): Boolean
Check whether all elements satisfy the predicate
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
groupBy[B](f: (A) ⇒ B)(implicit B: Order[B]): SortedMap[B, NonEmptyList[A]]
Groups elements inside this
NonEmptyList
according to theOrder
of the keys produced by the given mapping function.Groups elements inside this
NonEmptyList
according to theOrder
of the keys produced by the given mapping function.scala> import scala.collection.immutable.SortedMap scala> import cats.data.NonEmptyList scala> import cats.instances.boolean._ scala> val nel = NonEmptyList.of(12, -2, 3, -5) scala> nel.groupBy(_ >= 0) res0: SortedMap[Boolean, cats.data.NonEmptyList[Int]] = Map(false -> NonEmptyList(-2, -5), true -> NonEmptyList(12, 3))
-
def
groupByNem[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptyMap[B, NonEmptyList[A]]
Groups elements inside this
NonEmptyList
according to theOrder
of the keys produced by the given mapping function.Groups elements inside this
NonEmptyList
according to theOrder
of the keys produced by the given mapping function.scala> import cats.data._ scala> import cats.instances.boolean._ scala> val nel = NonEmptyList.of(12, -2, 3, -5) scala> nel.groupByNem(_ >= 0) res0: NonEmptyMap[Boolean, NonEmptyList[Int]] = Map(false -> NonEmptyList(-2, -5), true -> NonEmptyList(12, 3))
- val head: A
-
def
init: List[A]
Selects all elements except the last
Selects all elements except the last
scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5) scala> nel.init res0: scala.collection.immutable.List[Int] = List(1, 2, 3, 4)
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
last: A
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
- def length: Int
-
def
map[B](f: (A) ⇒ B): NonEmptyList[B]
Applies f to all the elements of the structure
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def prepend[AA >: A](a: AA): NonEmptyList[AA]
-
def
reduce[AA >: A](implicit S: Semigroup[AA]): AA
Reduce using the
Semigroup
ofAA
. -
def
reduceLeft[AA >: A](f: (AA, AA) ⇒ AA): AA
Left-associative reduce using f.
-
def
reverse: NonEmptyList[A]
Reverse this
NonEmptyList
.Reverse this
NonEmptyList
.scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of(1, 2, 3) scala> nel.reverse res0: cats.data.NonEmptyList[Int] = NonEmptyList(3, 2, 1)
- def show[AA >: A](implicit AA: Show[AA]): String
-
def
size: Int
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
-
def
sortBy[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptyList[A]
Sorts this
NonEmptyList
according to anOrder
on transformedB
fromA
Sorts this
NonEmptyList
according to anOrder
on transformedB
fromA
scala> import cats.data.NonEmptyList scala> import cats.instances.int._ scala> val nel = NonEmptyList.of(('a', 4), ('z', 1), ('e', 22)) scala> nel.sortBy(_._2) res0: cats.data.NonEmptyList[(Char, Int)] = NonEmptyList((z,1), (a,4), (e,22))
-
def
sorted[AA >: A](implicit AA: Order[AA]): NonEmptyList[AA]
Sorts this
NonEmptyList
according to anOrder
Sorts this
NonEmptyList
according to anOrder
scala> import cats.data.NonEmptyList scala> import cats.instances.int._ scala> val nel = NonEmptyList.of(12, 4, 3, 9) scala> nel.sorted res0: cats.data.NonEmptyList[Int] = NonEmptyList(3, 4, 9, 12)
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- val tail: List[A]
-
def
toList: List[A]
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)
-
def
toNem[T, U](implicit ev: <:<[A, (T, U)], order: Order[T]): NonEmptyMap[T, U]
Creates new
NonEmptyMap
, similarly to List#toMap from scala standard library.Creates new
NonEmptyMap
, similarly to List#toMap from scala standard library.scala> import cats.data._ scala> import cats.instances.int._ scala> val nel = NonEmptyList((0, "a"), List((1, "b"),(0, "c"), (2, "d"))) scala> nel.toNem res0: NonEmptyMap[Int,String] = Map(0 -> c, 1 -> b, 2 -> d)
-
def
toNes[B >: A](implicit order: Order[B]): NonEmptySet[B]
Creates new
NonEmptySet
, similarly to List#toSet from scala standard library.Creates new
NonEmptySet
, similarly to List#toSet from scala standard library.scala> import cats.data._ scala> import cats.instances.int._ scala> val nel = NonEmptyList(1, List(2,2,3,4)) scala> nel.toNes res0: cats.data.NonEmptySet[Int] = TreeSet(1, 2, 3, 4)
-
def
toString(): String
- Definition Classes
- NonEmptyList → AnyRef → Any
- def traverse[G[_], B](f: (A) ⇒ G[B])(implicit G: Applicative[G]): G[NonEmptyList[B]]
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
zipWith[B, C](b: NonEmptyList[B])(f: (A, B) ⇒ C): NonEmptyList[C]
Zips this
NonEmptyList
with anotherNonEmptyList
and applies a function for each pair of elements.Zips this
NonEmptyList
with anotherNonEmptyList
and applies a function for each pair of elements.scala> import cats.data.NonEmptyList scala> val as = NonEmptyList.of(1, 2, 3) scala> val bs = NonEmptyList.of("A", "B", "C") scala> as.zipWith(bs)(_ + _) res0: cats.data.NonEmptyList[String] = NonEmptyList(1A, 2B, 3C)
-
def
zipWithIndex: NonEmptyList[(A, Int)]
Zips each element of this
NonEmptyList
with its index.Zips each element of this
NonEmptyList
with its index.scala> import cats.data.NonEmptyList scala> val nel = NonEmptyList.of("a", "b", "c") scala> nel.zipWithIndex res0: cats.data.NonEmptyList[(String, Int)] = NonEmptyList((a,0), (b,1), (c,2))
Deprecated Value Members
-
def
concat[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA]
- Annotations
- @deprecated
- Deprecated
(Since version 1.0.0-RC1) Use concatNel