_evaluate

trait _evaluate
class java.lang.Object
trait scala.Matchable
class Any
trait _use
object ~

Def

def contains[A](value: A): Boolean

Value check

Value check

Returns true if stream contains given value.

Source
_evaluate.scala
def count[A]: Int

All count

All count

Counts all stream elements

Source
_evaluate.scala
def count[A](f: A => Boolean): Int

Conditional count

Conditional count

Counts all stream elements, which satisfy given predicate

Source
_evaluate.scala
def countAndTime[A]: (Int, Time.Length)

Count and time

Count and time

Returns all elements count and Time.Length it took to pump the stream

  val (cnt,time) = (1 <> 1000).~.peek(_ => J.sleep(1.Millis)).countAndTime

  ("" + cnt + " elements processed in " + time.tag).tp

  // Output
  1000 elements processed in 1.488880500 sec
Source
_evaluate.scala
def countFew[A](f1: A => Boolean, f2: A => Boolean, f3: A => Boolean, f4: A => Boolean, f5: A => Boolean): (Int, Int) | (Int, Int, Int) | (Int, Int, Int, Int) | (Int, Int, Int, Int, Int)

Multi count

Multi count

Simultaneously counts values for up to 5 different predicates

Returns tuple of appropriate size with values corresponding to the given mappings

For empty Stream returned tuple will hold zeros

val (large, odd, even) = (1 <>> 1000).~.countFew(_ > 100, _ % 2 == 0, _ % 2 == 1)

large.tp    // Prints 899
odd.tp      // Prints 499
even.tp     // Prints 500
Source
_evaluate.scala
def equalsAll[A](v: ~[A]): Boolean

Equal check

Equal check

Iterates both streams and compares all corresponding elements

Returns true if all are equal, `false`` otherwise

Source
_evaluate.scala
@scala.annotation.targetName("equalsAll_Result")
def equalsAll_??[A](v: ~[A]): Result[true]

Equal check

Equal check

Iterates both streams and compares all corresponding elements

When first not equal pair is found, the problem result is returned

If all elements are equal, Result[true] is returned

(0 <> 10).~.equalsAll_??(0 <> 10).tp
// Prints: Result(true)

(0 <> 10).~.equalsAll_??(0 <>> 10).tp
// Prints: Result(Problem(Second stream has less elements))

((0 <> 5).~ + 7 + 8).equalsAll_??(0 <> 10).tp
// Prints: Result(Problem(Fail at index 6: 7 != 6))

Note: The returned problem contains message with basic description

Source
_evaluate.scala
def equalsStart[A](v: ~[A]): Boolean

Equal start check

Equal start check

Checks if starting elements of two streams (to a point where one stream ends) are equal

Source
_evaluate.scala
@scala.annotation.targetName("equalsStart_Result")
def equalsStart_??[A](v: ~[A]): Result[true]

Equal start check

Equal start check

Checks if starting elements of two streams (to a point where one stream ends) are equal

(0 <> 10).~.equalsStart_??(0 <> 1000).tp
// Prints: Result(true)

(0 <> 1000).~.equalsStart_??(0 <> 10).tp
// Prints: Result(true)

((0 <> 5).~ + 7 + 8).equalsStart_??(0 <> 10).tp
// Prints: Result(Problem(Fail at index 6: 7 != 6))

Note: The returned problem result contains message with basic description

Source
_evaluate.scala
def exists[A](f: A => Boolean): Boolean

Exists check

Exists check

Returns true if there is an elemnet satisfying given predicate

Source
_evaluate.scala
def find[A](f: A => Boolean): A

Find value

Find value

Finds the first value accepted by given predicate

 (1 <> 1000).~.find(_ > 100).tp  // Prints 101

Note: If value is not found find fails, use find_? in most cases

Source
_evaluate.scala
@scala.annotation.targetName("find_Opt")
def find_?[A](f: A => Boolean): Opt[A]

Optional find value

Optional find value

Finds the first value accepted by given predicate or returns void option if not found

(1 <> 1000).~.find_?(_ > 100).tp   // Prints Opt(101)

(1 <> 10).~.find_?(_ > 100).tp     // Prints Opt(\/)
Source
_evaluate.scala
@scala.annotation.targetName("findPosition_Opt")
def findPosition_?[A](f: A => Boolean): Int.Opt

Find index

Find index

Optionally returns index for the first element satisfying the predicate or Int.Opt(/) if none found

  (50 <> 500).~.findPosition_?(_ == 400)  // Retuns Int.Opt(350)
Source
_evaluate.scala
def isEvery[A](f: A => Boolean): Boolean

Forall check

Forall check

Returns true if every single element satisfies the given predicate

Source
_evaluate.scala
def last[A]: A

Last element

Last element

Returns the last stream element

Fails if empty

Source
_evaluate.scala
@scala.annotation.targetName("last_Opt")
def last_?[A]: Opt[A]

Last element

Last element

Optionally returns the last element or Opt(/)

Source
_evaluate.scala