VectorOps
Attributes
- Source
- vector.scala
- Graph
-
- Supertypes
-
class AnyValtrait Matchableclass Any
Members list
Value members
Concrete methods
Groups elements inside this Vector
according to the Order
of the keys produced by the given mapping function.
Groups elements inside this Vector
according to the Order
of the keys produced by the given mapping function.
scala> import cats.data.NonEmptyVector
scala> import scala.collection.immutable.SortedMap
scala> import cats.syntax.all._
scala> val vector = Vector(12, -2, 3, -5)
scala> val expectedResult = SortedMap(false -> NonEmptyVector.of(-2, -5), true -> NonEmptyVector.of(12, 3))
scala> vector.groupByNev(_ >= 0) === expectedResult
res0: Boolean = true
Attributes
- Source
- vector.scala
Groups elements inside this Vector
according to the Order
of the keys produced by the given mapping monadic function.
Groups elements inside this Vector
according to the Order
of the keys produced by the given mapping monadic function.
scala> import cats.data.NonEmptyVector
scala> import scala.collection.immutable.SortedMap
scala> import cats.syntax.all._
scala> val vector = Vector(12, -2, 3, -5)
scala> val expectedResult = Option(SortedMap(false -> NonEmptyVector.of(-2, -5), true -> NonEmptyVector.of(12, 3)))
scala> vector.groupByNevA(num => Option(0).map(num >= _)) === expectedResult
res0: Boolean = true
Attributes
- Source
- vector.scala
Produces a NonEmptyVector
containing cumulative results of applying the operator going left to right.
Produces a NonEmptyVector
containing cumulative results of applying the operator going left to right.
Example:
scala> import cats.data.NonEmptyVector
scala> import cats.syntax.all._
scala> val result1: Vector[Int] = Vector(1, 2)
scala> result1.scanLeftNev(100)(_ + _)
res0: NonEmptyVector[Int] = NonEmptyVector(100, 101, 103)
scala> val result2: Vector[Int] = Vector.empty[Int]
scala> result2.scanLeftNev(1)(_ + _)
res1: NonEmptyVector[Int] = NonEmptyVector(1)
Attributes
- Source
- vector.scala
Produces a NonEmptyVector
containing cumulative results of applying the operator going right to left.
Produces a NonEmptyVector
containing cumulative results of applying the operator going right to left.
Example:
scala> import cats.data.NonEmptyVector
scala> import cats.syntax.all._
scala> val result1: Vector[Int] = Vector(1, 2)
scala> result1.scanRightNev(100)(_ + _)
res0: NonEmptyVector[Int] = NonEmptyVector(103, 102, 100)
scala> val result2: Vector[Int] = Vector.empty[Int]
scala> result2.scanRightNev(1)(_ + _)
res1: NonEmptyVector[Int] = NonEmptyVector(1)
Attributes
- Source
- vector.scala
Returns an Option of NonEmptyVector from a Vector
Returns an Option of NonEmptyVector from a Vector
Example:
scala> import cats.data.NonEmptyVector
scala> import cats.syntax.all._
scala> val result1: Vector[Int] = Vector(1, 2)
scala> result1.toNev
res0: Option[NonEmptyVector[Int]] = Some(NonEmptyVector(1, 2))
scala> val result2: Vector[Int] = Vector.empty[Int]
scala> result2.toNev
res1: Option[NonEmptyVector[Int]] = None
Attributes
- Source
- vector.scala