_drop

trait _drop[A]
class java.lang.Object
trait scala.Matchable
class Any
trait _filter
trait _build
object Stream

Def

inline def drop(f: A => Boolean): Stream[A]

Reverse filter

Reverse filter

Disallows Stream elements satisfying the given function

  (0 <>> 10).stream.drop(_ > 5).tp

  // Output
  Stream(0, 1, 2, 3, 4, 5)

Note: Scala equivalent is called "filterNot"

Source
_drop.scala
inline def DROP(f: A => Boolean): Stream[A]

Heavy reversed filter

Heavy reversed filter

Disallows Stream elements satisfying the given function

DROP is functionally equivalent to drop, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.

Source
_drop.scala
inline def dropDuplicates: Stream[A]

Duplicates reversed filter

Duplicates reversed filter

Drops elements equal to the passed in prior position

Note: To generally get rid of all duplicates, the stream must be sorted to arrange duplicates in sequence

(1 <> 10).stream.repeat(3).dropDuplicates.tp // Prints Stream(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Source
_drop.scala
inline def dropDuplicatesBy[B](f: A => B): Stream[A]

Mapped duplicates reversed filter

Mapped duplicates reversed filter

Drops elements, which evaluate to the same value as elements passed in prior position

Note: To generally get rid of all duplicates, the stream must be sorted by the mapping function

  (1 <> 100).stream.dropDuplicatesBy(_.toString.length).tp

  // Output
  Stream(1, 10, 100)
Source
_drop.scala
inline def dropEvery(nTh: Int): Stream[A]

Every Nth element reversed filter

Every Nth element reversed filter

Drops every nTh element

  (1 <> 10).stream.dropEvery(3).tp   // Prints: Stream(1, 2, 4, 5, 7, 8, 10)
Source
_drop.scala
inline def dropFirst(n: Int): Stream[A]

Head reversed filter

Head reversed filter

Drops given number of first elements

  (1 <> 10).stream.dropFirst(3).tp  // Prints  Stream(4, 5, 6, 7, 8, 9, 10)
Source
_drop.scala
inline def dropLast(n: Int): Stream[A]

Tail reversed filter

Tail reversed filter

Drops given number of elements coming last

  (1 <> 10).stream.dropLast(3).tp  // Prints  Stream(1, 2, 3, 4, 5, 6, 7)

Note: This method will block on unlimited streams

Source
_drop.scala
inline def dropOnly(v: A): Stream[A]

Single value reversed filter

Single value reversed filter

Drops only specified value.

  (1 <> 4).stream.dropOnly(3).tp

  // Output
  Stream(1, 2, 4)

Note: dropOnly is more efficient than general filter ".drop(_ == value)", because there is no function involved.

Source
_drop.scala
inline def dropRange(i: Int.Range): Stream[A]

Range reversed filter

Range reversed filter

Only allows elements outside specified sequencial range

  ('a' <> 'f').stream.dropRange(2 <> 3).tp

  // Output
  Stream(a, b, e, f)

Note: Range indexing starts from 0

Source
_drop.scala
inline def dropSequence(seq: Stream[A]): Stream[A]
inline def dropSequenceBy[B](f: A => B, seq: Stream[B]): Stream[A]
inline def dropValues(v: Stream[A]): Stream[A]

Multi value reversed filter

Multi value reversed filter

Drops only provided set of values

  (0 <>> 10).stream.dropValues(8,3,5).tp

  // Output
  Stream(0, 1, 2, 4, 6, 7, 9)

Note: dropValues is macro optimized when given value tuples sized from 2 to 5

Source
_drop.scala
inline def dropValuesBy[B](f: A => B, v: Stream[B]): Stream[A]

Mapped multi value reversed filter

Mapped multi value reversed filter

Drops only values, which convert to provided set of values

  (0 <>> 10).stream.dropValuesBy(_ % 5, (1,3) ).tp

  // Output
  Stream(0, 2, 4, 5, 7, 9)

Note: dropValuesBy is macro optimized when given value tuples sized from 2 to 5

Source
_drop.scala
inline def dropVoid(using d: Any.Def.Void[A]): Stream[A]

Void value reversed filter

Void value reversed filter

Drops elements which test to be void

Source
_drop.scala
inline def dropWhile(f: A => Boolean): Stream[A]

Coditional reversed head filter

Coditional reversed head filter

Discards first consecutive elements satisfying the condition

  def stream = (1 <> 5).stream ++ (1 <> 5)

  stream.tp                     // Prints Stream(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)

  stream.dropWhile(_ <= 3).tp   // Prints Stream(4, 5, 1, 2, 3, 4, 5)

Note: Everything starting from the first non compliant element will be allowed (including later compliant elements)

Source
_drop.scala