FP
Various utilities for functional programming.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
FP.type
Members list
Value members
Concrete methods
Method to determine if the String w was found at a valid index (i).
Method to determine if the String w was found at a valid index (i).
Value parameters
- i
-
the index found.
- w
-
the String (ignored unless there's an exception).
Attributes
- Returns
-
Success(i) if all well, else Failure(exception).
Method to partition an Iterator.
Method to partition an Iterator.
Type parameters
- X
-
the underlying type.
Value parameters
- xys
-
an Iterator of Try[X].
Attributes
- Returns
-
a tuple of two iterators of Try[X], the first one being successes, the second one being failures.
Method to partition an method to combine elements of Try.
Method to partition an method to combine elements of Try.
Type parameters
- X
-
the underlying type.
Value parameters
- xys
-
a Seq of Try[X].
Attributes
- Returns
-
a tuple of two Seqs of Try[X], the first one being successes, the second one being failures.
Attempts to recover the value from a computation represented as a lazy Try[Option[X]]. If the computation succeeds, it returns the contained Option[X]. If the computation fails with a non-fatal exception, the exception is passed to the provided recovery function, and the result is None. Fatal exceptions are rethrown.
Attempts to recover the value from a computation represented as a lazy Try[Option[X]]. If the computation succeeds, it returns the contained Option[X]. If the computation fails with a non-fatal exception, the exception is passed to the provided recovery function, and the result is None. Fatal exceptions are rethrown.
Type parameters
- X
-
The underlying type of the
Option.
Value parameters
- f
-
A function to handle non-fatal exceptions encountered during evaluation of
xy. - xy
-
A lazy computation resulting in a
Try[Option[X]]. It is evaluated when the method is invoked.
Attributes
- Returns
-
The
Option[X]value if successful,Noneif a non-fatal exception occurs, or the exception is rethrown if it is fatal.
Method to yield a URL for a given resourceForClass in the classpath for C.
Method to yield a URL for a given resourceForClass in the classpath for C.
Type parameters
- C
-
a class of the package containing the resourceForClass.
Value parameters
- resourceName
-
the name of the resourceForClass.
Attributes
- Returns
-
a
Try[URL].
Method to yield a Try[URL] for a resource name and a given class.
Method to yield a Try[URL] for a resource name and a given class.
Value parameters
- clazz
-
the class, relative to which the resource can be found (defaults to the caller's class).
- resourceName
-
the name of the resource.
Attributes
- Returns
-
a Try[URL]
Method to return a random sampling function.
Method to return a random sampling function.
Type parameters
- X
-
the underlying type of the sampler.
Value parameters
- n
-
this is the sample factor: approximately one in every n successful results will form part of the result.
- r
-
(implicit) Random source of entropy.
Attributes
- Returns
-
an
X => Booleanfunction which is always yields false if its input is a failure, otherwise, it chooses every nth value (approximately).
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
CONSIDER invoking sequenceRev
Type parameters
- X
-
the underlying type
Value parameters
- xys
-
an Iterator of Try[X]
Attributes
- Returns
-
a Try of Iterator[X]
Sequence method to combine elements of Try while retaining their original order.
Sequence method to combine elements of Try while retaining their original order.
Type parameters
- X
-
the underlying type
Value parameters
- xys
-
an Iterable of Try[X]
Attributes
- Returns
-
a Try of Seq[X] NOTE: that the output collection type will be Seq, regardless of the input type
Sequence method to combine elements of type Option[X]. The result is not defined unless all/any? of the elements are defined.
Sequence method to combine elements of type Option[X]. The result is not defined unless all/any? of the elements are defined.
NOTE that the order of the resulting values will be the reverse of the input. This is for performance reasons.
Type parameters
- X
-
the underlying type.
Value parameters
- xos
-
an Iterable of Option[X].
Attributes
- Returns
-
an Option of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type CONSIDER using Builder
Sequence method to combine elements of Option[X]. The result is defined unless all the elements are None.
Sequence method to combine elements of Option[X]. The result is defined unless all the elements are None.
NOTE that the order of the resulting values will be the reverse of the iterator. This is for performance reasons.
Type parameters
- X
-
the underlying type.
Value parameters
- xos
-
an Iterable of Option[X].
Attributes
- Returns
-
an Option of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
Type parameters
- X
-
the underlying type.
Value parameters
- xys
-
an Iterable of Try[X].
Attributes
- Returns
-
a Try of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
Type parameters
- X
-
the underlying type.
Value parameters
- fSuccess
-
a function of type X => Try of Option[X].
- pfFailure
-
a partial function of type Throwable => Try of Option[X].
- xys
-
an Iterable of Try[X].
Attributes
- Returns
-
a Try of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
Type parameters
- X
-
the underlying type.
Value parameters
- pfFailure
-
a partial function of type Throwable => Try of Option[X].
- xys
-
an Iterable of Try[X].
Attributes
- Returns
-
a Try of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type
Sequence (inclusive) method to combine elements of type Option[X]. The result is defined unless all the elements are None.
Sequence (inclusive) method to combine elements of type Option[X]. The result is defined unless all the elements are None.
NOTE that the order of the resulting values will be the reverse of the input. This is for performance reasons.
Type parameters
- X
-
the underlying type.
Value parameters
- xos
-
an Iterable of Option[X].
Attributes
- Returns
-
an Option of Seq[X]. NOTE: that the output collection type will be Seq, regardless of the input type
Sequence method to combine elements of Try.
Sequence method to combine elements of Try.
NOTE: this method is much faster than sequence but does return the elements in their reverse order.
Type parameters
- X
-
the underlying type
Value parameters
- xys
-
an Iterable of Try[X]
Attributes
- Returns
-
a Try of Seq[X] NOTE: that the output collection type will be Seq, regardless of the input type
Method to transform a Try[X] into an Option[X]. But, unlike "toOption," a Failure can be logged.
Method to transform a Try[X] into an Option[X]. But, unlike "toOption," a Failure can be logged.
Type parameters
- X
-
the underlying type.
Value parameters
- f
-
a function to process any Exception (typically a logging function).
- xy
-
the input Try[X].
Attributes
- Returns
-
an Option[X].