Packages

c

cats.syntax

ListOps

final class ListOps[A] extends AnyVal

Source
list.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ListOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ListOps(la: List[A])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  6. def groupByNel[B](f: (A) ⇒ B)(implicit B: Order[B]): SortedMap[B, NonEmptyList[A]]

    Groups elements inside this List according to the Order of the keys produced by the given mapping function.

    Groups elements inside this List according to the Order of the keys produced by the given mapping function.

    scala> import cats.data.NonEmptyList
    scala> import scala.collection.immutable.SortedMap
    scala> import cats.implicits._
    
    scala> val list = List(12, -2, 3, -5)
    
    scala> val expectedResult = SortedMap(false -> NonEmptyList.of(-2, -5), true -> NonEmptyList.of(12, 3))
    
    scala> list.groupByNel(_ >= 0) === expectedResult
    res0: Boolean = true
  7. def groupByNelA[F[_], B](f: (A) ⇒ F[B])(implicit F: Applicative[F], B: Order[B]): F[SortedMap[B, NonEmptyList[A]]]

    Groups elements inside this List according to the Order of the keys produced by the given mapping monadic function.

    Groups elements inside this List according to the Order of the keys produced by the given mapping monadic function.

    scala> import cats.data.NonEmptyList
    scala> import scala.collection.immutable.SortedMap
    scala> import cats.implicits._
    
    scala> val list = List(12, -2, 3, -5)
    
    scala> val expectedResult = Option(SortedMap(false -> NonEmptyList.of(-2, -5), true -> NonEmptyList.of(12, 3)))
    
    scala> list.groupByNelA(num => Option(0).map(num >= _)) === expectedResult
    res0: Boolean = true
  8. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  9. def scanLeftNel[B](b: B)(f: (B, A) ⇒ B): NonEmptyList[B]

    Produces a NonEmptyList containing cumulative results of applying the operator going left to right.

    Produces a NonEmptyList containing cumulative results of applying the operator going left to right.

    Example:

    scala> import cats.data.NonEmptyList
    scala> import cats.implicits._
    
    scala> val result1: List[Int] = List(1, 2)
    scala> result1.scanLeftNel(100)(_ + _)
    res0: NonEmptyList[Int] = NonEmptyList(100, 101, 103)
    
    scala> val result2: List[Int] = List.empty[Int]
    scala> result2.scanLeftNel(1)(_ + _)
    res1: NonEmptyList[Int] = NonEmptyList(1)
  10. def scanRightNel[B](b: B)(f: (A, B) ⇒ B): NonEmptyList[B]

    Produces a NonEmptyList containing cumulative results of applying the operator going right to left.

    Produces a NonEmptyList containing cumulative results of applying the operator going right to left.

    Example:

    scala> import cats.data.NonEmptyList
    scala> import cats.implicits._
    
    scala> val result1: List[Int] = List(1, 2)
    scala> result1.scanRightNel(100)(_ + _)
    res0: NonEmptyList[Int] = NonEmptyList(103, 102, 100)
    
    scala> val result2: List[Int] = List.empty[Int]
    scala> result2.scanRightNel(1)(_ + _)
    res1: NonEmptyList[Int] = NonEmptyList(1)
  11. def toNel: Option[NonEmptyList[A]]

    Returns an Option of NonEmptyList from a List

    Returns an Option of NonEmptyList from a List

    Example:

    scala> import cats.data.NonEmptyList
    scala> import cats.implicits._
    
    scala> val result1: List[Int] = List(1, 2)
    scala> result1.toNel
    res0: Option[NonEmptyList[Int]] = Some(NonEmptyList(1, 2))
    
    scala> val result2: List[Int] = List.empty[Int]
    scala> result2.toNel
    res1: Option[NonEmptyList[Int]] = None
  12. def toString(): String
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped