_filter

trait _Filter[A] extends _take[A] with _drop[A]
trait _drop
trait _take
class java.lang.Object
trait scala.Matchable
class Any
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"

Inherited from
_drop
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.

Inherited from
_drop
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)
Inherited from
_drop
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)
Inherited from
_drop
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)
Inherited from
_drop
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)
Inherited from
_drop
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

Inherited from
_drop
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.

Inherited from
_drop
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

Inherited from
_drop
Source
_drop.scala
inline def dropSequence(seq: Stream[A]): Stream[A]
Inherited from
_drop
Source
_drop.scala
inline def dropSequenceBy[B](f: A => B, seq: Stream[B]): Stream[A]
Inherited from
_drop
Source
_drop.scala
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

Inherited from
_drop
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

Inherited from
_drop
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

Inherited from
_drop
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)

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

Legacy filter

Legacy filter

Filters Stream elements according to given function

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

  // Output
  Stream(6, 7, 8, 9)

Note: take is usually used instead.

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

Legacy heavy filter

Legacy heavy filter

Filters Stream elements according to given function

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

Note: TAKE is usually used instead.

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

Main filter

Main filter

Only takes Stream elements satisfying the given function

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

  // Output
  Stream(6, 7, 8, 9)

Note: Traditional method filter is also available and can be used, but take is prefferable in most cases.

Inherited from
_take
Source
_take.scala
inline def TAKE(f: A => Boolean): Stream[A]

Heavy filter

Heavy filter

Filters Stream elements according to given function

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

Inherited from
_take
Source
_take.scala
inline def takeDuplicates: Stream[A]

Duplicates filter

Duplicates filter

Takes only elements equal to the passed in prior position

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

   Stream(1,1,2,3,3,4,5,5,5).takeDuplicates.tp

   // Output
   Stream(1, 3, 5, 5)
Inherited from
_take
Source
_take.scala
inline def takeDuplicatesBy[B](f: A => B): Stream[A]

Mapped duplicates filter

Mapped duplicates filter

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

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

  (0 <> 10).stream.takeDuplicatesBy(_ / 2).tp

  // Output
  Stream(1, 3, 5, 7, 9)
Inherited from
_take
Source
_take.scala
inline def takeEvery(nTh: Int): Stream[A]

Every Nth element filter

Every Nth element filter

Only lets every nTh element

  (1 <> 20).stream.takeEvery(4).tp   // Prints: Stream(4, 8, 12, 16, 20)
Inherited from
_take
Source
_take.scala
inline def takeFirst(n: Int): Stream[A]

Head filter

Head filter

Only takes given number of first elements

  (1 <> 10).stream.takeFirst(3).tp  // Prints  Stream(1, 2, 3)
Inherited from
_take
Source
_take.scala
inline def takeIndexed(f: (Int, A) => Boolean, start: Int): Stream[A]

Indexed filter

Indexed filter

Only lets elements satisfying the given function, which also accepts element sequential index

  ('a' <> 'z').stream.takeIndexed((i, _) => i >= 2 && i <= 7, 1).tp

  // Output
  Stream(b, c, d, e, f, g)

Note: By default indexing starts from 0, but starting value can also be explicitly specified.

Inherited from
_take
Source
_take.scala
inline def takeLast(n: Int): Stream[A]

Tail filter

Tail filter

Only takes given number of elements coming last

  (1 <> 10).stream.takeLast(3).tp  // Prints  Stream(8, 9, 10)

Note: This method will block on unlimited streams

Inherited from
_take
Source
_take.scala
inline def takeOnly(v: A): Stream[A]

Single value filter

Single value filter

Filters only specified value.

  (0 <>> 10).stream.takeOnly(5).tp

  // Output
  Stream(5)

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

Inherited from
_take
Source
_take.scala
inline def takeRange(i: Int.Range): Stream[A]

Range filter

Range filter

Only allows elements withing specified sequencial range

  ('a' <> 'z').stream.takeRange(1 <> 7).tp

  // Output
  Stream(b, c, d, e, f, g, h)

Note: Range indexing starts from 0

Inherited from
_take
Source
_take.scala
inline def takeType[B](using t: scala.reflect.ClassTag[B]): Stream[B]

Type filter

Type filter

Only lets elements of specified type

  Stream(1, '2', "3", new Object(), 0.0).takeType[String].tp  // Prints: Stream(3)
Inherited from
_take
Source
_take.scala
inline def takeValues(v: Stream[A]): Stream[A]

Multi value filter

Multi value filter

Takes only provided set of values

    ('a' <> 'z').stream.takeValues('z','x','b').tp   // Prints Stream('b','x','y')

    ('a' <> 'z').stream.takeValues('b' <> 'f').tp    // Prints Stream('b','c','d','e','f')

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

Inherited from
_take
Source
_take.scala
inline def takeValuesBy[B](f: A => B, v: Stream[B]): Stream[A]

Mapped multi value filter

Mapped multi value filter

Takes only values, which convert to provided set of values

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

  // Output
  Stream(1, 3, 6, 8)

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

Inherited from
_take
Source
_take.scala
inline def takeWhile(f: A => Boolean): Stream[A]

Conditional head filter

Conditional head filter

Only takes 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.takeWhile(_ <= 3).tp    // Prints Stream(1, 2, 3)

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

Inherited from
_take
Source
_take.scala