_evaluate
Def
Sequence check
Sequence check
Returns true if stream contains given sequence of values.
- Source
- _evaluate.scala
Conditional count
Conditional count
Counts all stream elements, which satisfy given predicate
- Source
- _evaluate.scala
Count and time
Count and time
Returns all elements count and Time.Length it took to pump the stream
val (cnt,time) = (1 <> 1000).stream.peek(_ => J.sleep(1.Millis)).countAndTime
("" + cnt + " elements processed in " + time.tag).tp
// Output
1000 elements processed in 1.488880500 sec
- Source
- _evaluate.scala
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).stream.countFew(_ > 100, _ % 2 == 0, _ % 2 == 1)
large.tp // Prints 899
odd.tp // Prints 499
even.tp // Prints 500
- Source
- _evaluate.scala
Equal check
Equal check
Iterates both streams and compares all corresponding elements
Returns true
if all are equal, `false`` otherwise
- Source
- _evaluate.scala
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).stream.equalsAllResult(0 <> 10).tp
// Prints: Result(true)
(0 <> 10).stream.equalsAllResult(0 <>> 10).tp
// Prints: Result(Problem(Second stream has less elements))
((0 <> 5).stream + 7 + 8).equalsAllResult(0 <> 10).tp
// Prints: Result(Problem(Fail at index 6: 7 != 6))
Note: The returned problem contains message with basic description
- Source
- _evaluate.scala
Exists check
Exists check
Returns true if there is an elemnet satisfying given predicate
- Source
- _evaluate.scala
Find value
Find value
Finds the first value accepted by given predicate
(1 <> 1000).stream.find(_ > 100).tp // Prints 101
Note: If value is not found find fails, use findOpt in most cases
- Source
- _evaluate.scala
Optional find value
Optional find value
Finds the first value accepted by given predicate or returns void option if not found
(1 <> 1000).stream.findOpt(_ > 100).tp // Prints Opt(101)
(1 <> 10).stream.findOpt(_ > 100).tp // Prints Opt(VOID)
- Source
- _evaluate.scala
Find index
Find index
Optionally returns index for the first element satisfying the predicate or Int.Opt(VOID) if none found
(50 <> 500).stream.findPositionOpt(_ == 400) // Retuns Int.Opt(350)
- Source
- _evaluate.scala
Find start index
Find start index
Optionally returns index where given stream value sequence matches current stream values
- Source
- _evaluate.scala
Forall check
Forall check
Returns true if every single element satisfies the given predicate
- Source
- _evaluate.scala
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
Equal start check
Equal start check
Checks if starting elements of two streams (to a point where one stream ends) are equal
(0 <> 10).stream.equalsStartResult(0 <> 1000).tp
// Prints: Result(true)
(0 <> 1000).stream.equalsStartResult(0 <> 10).tp
// Prints: Result(true)
((0 <> 5).stream + 7 + 8).equalsStartResult(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