object Fold extends CompatFold with Serializable
Methods to create and run Folds.
The Folds defined here are immutable and serializable, which we expect by default. It is important that you as a user indicate mutability or non-serializability when defining new Folds. Additionally, it is recommended that "end" functions not mutate the accumulator in order to support scans (producing a stream of intermediate outputs by calling "end" at each step).
- Alphabetic
- By Inheritance
- Fold
- Serializable
- CompatFold
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- implicit def applicative[I]: Applicative[[β$0$]Fold[I, β$0$]]
"import Fold.applicative" will bring the Applicative instance into scope.
"import Fold.applicative" will bring the Applicative instance into scope. See FoldApplicative.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def const[O](value: O): Fold[Any, O]
A Fold that does no work and returns a constant.
A Fold that does no work and returns a constant. Analogous to Function1 const: def const[A, B](b: B): (A => B) = { _ => b }
- def container[I, C[_]](implicit cbf: Factory[I, C[I]]): Fold[I, C[I]]
Simple Fold that collects elements into a container.
Simple Fold that collects elements into a container.
- Definition Classes
- CompatFold
- def count[I](pred: (I) => Boolean): Fold[I, Long]
A Fold that counts the number of elements satisfying the predicate.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def exists[I](pred: (I) => Boolean): Fold[I, Boolean]
A Fold that returns "true" if any element of the sequence statisfies the predicate.
A Fold that returns "true" if any element of the sequence statisfies the predicate. Note this does not short-circuit enumeration of the sequence.
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def first[I]: Fold[I, Option[I]]
A Fold that returns the first value in a sequence.
- def fold[M, I, O](add: (M, I) => M, start: M, end: (M) => O): Fold[I, O]
A general way of defining Folds that supports a separate accumulator type.
A general way of defining Folds that supports a separate accumulator type. The accumulator MUST be immutable and serializable.
- def foldLeft[I, O](o: O)(add: (O, I) => O): Fold[I, O]
Turn a common Scala foldLeft into a Fold.
Turn a common Scala foldLeft into a Fold. The accumulator MUST be immutable and serializable.
- def foldMutable[M, I, O](add: (M, I) => M, start: (Unit) => M, end: (M) => O): Fold[I, O]
A general way of defining Folds that supports constructing mutable or non-serializable accumulators.
- def forall[I](pred: (I) => Boolean): Fold[I, Boolean]
A Fold that returns "true" if all elements of the sequence statisfy the predicate.
A Fold that returns "true" if all elements of the sequence statisfy the predicate. Note this does not short-circuit enumeration of the sequence.
- def foreach[I](e: (I) => Unit): Fold[I, Unit]
A Fold that runs the given side effect for every element.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def last[I]: Fold[I, Option[I]]
A Fold that returns the last value in a sequence.
- def max[I](implicit ordering: Ordering[I]): Fold[I, Option[I]]
A Fold that returns the max value in a sequence.
A Fold that returns the max value in a sequence. (Biased to earlier equal values.)
- def min[I](implicit ordering: Ordering[I]): Fold[I, Option[I]]
A Fold that returns a min value in a sequence.
A Fold that returns a min value in a sequence. (Biased to earlier equal values.)
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def product[I](implicit numeric: Ring[I]): Fold[I, I]
A Fold that returns the product of a numeric sequence.
A Fold that returns the product of a numeric sequence. Does not protect against overflow.
- def seq[I]: Fold[I, Seq[I]]
An even simpler Fold that collects into a Seq.
An even simpler Fold that collects into a Seq. Shorthand for "container[I, Seq];" fewer type arguments, better type inferrence.
- def sequence[I, O](ms: Seq[Fold[I, O]]): Fold[I, Seq[O]]
Fuse a sequence of Folds into one that outputs the result of each.
- def size: Fold[Any, Long]
A Fold that returns the length of a sequence.
- def sum[I](implicit numeric: Monoid[I]): Fold[I, I]
A Fold that returns the sum of a numeric sequence.
A Fold that returns the sum of a numeric sequence. Does not protect against overflow.
- def sumOption[T](implicit sg: Semigroup[T]): Fold[T, Option[T]]
For a semigroup, if we get more than 0 items, use plus
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()