FP

com.phasmidsoftware.lascala.fp.FP
object FP

This is a collection of general functional-programming-style methods. We could probably get these from ScalaZ but I'd rather have no dependencies.

TODO flesh out the unit tests (coverage is low).

TODO replace as an output type with type based on CanBuildFrom

CONSIDER replace Seq with Iterator in signatures

CONSIDER use higher-kinded monad types in order to implement methods for Try and Option at the same time

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
FP.type

Members list

Value members

Concrete methods

def asFuture[X](xy: => Try[X]): Future[X]
def contains[X](ox: Option[X], x: X): Boolean

Type parameters

X

the underlying type

Value parameters

ox

the given Option

x

the value we want to compare with ox

Attributes

Returns

true if ox is Some(x)

def discriminate[X](x1: X, x2: X)(f: (X, X) => Int)(g: (X, X) => Int): Int

Method to discriminate between (compare) two objects. This differs from regular comparison in that if the result of the primary comparison is zero, we try to discriminate by invoking the secondary comparator.

Method to discriminate between (compare) two objects. This differs from regular comparison in that if the result of the primary comparison is zero, we try to discriminate by invoking the secondary comparator.

Type parameters

X

the underlying type

Value parameters

f

the primary comparator

g

the secondary comparator

x1

the first object

x2

the second object

Attributes

Returns

a negative number if x1 is "less than" x2; a positive number if x1 is "greater than" x2; otherwise 0

def flatMap2g[T1, T2, R](t1o: Option[T1], t2o: => Option[T2])(f: (T1, T2) => R, g: (T1, T2) => Option[Boolean]): Option[R]

An alternative method to map a pair of Option values (of same underlying type) into an Option value of another type (which could be the same of course) but with an additional guard function. If the guard function returns false, the f function will not be called and None will result.

An alternative method to map a pair of Option values (of same underlying type) into an Option value of another type (which could be the same of course) but with an additional guard function. If the guard function returns false, the f function will not be called and None will result.

Type parameters

R

the result type

T1

the underlying type of the first parameter

Value parameters

f

function which takes a T1 and a T2 parameter and yields a R result

g

guard function which takes a T1 and a T2 parameter and yields a Option[Boolean] result

t1o

a Option[T1] value

t2o

a Option[T2] value

Attributes

Returns

a Option[U]

def flatten[X](xyf: Future[Try[X]])(implicit executor: ExecutionContext): Future[X]
def flatten[X](xfy: Try[Future[X]]): Future[X]

this isn't a particularly useful method: basically, it just strips away the Try part, returning an un-fulfilled Future.

this isn't a particularly useful method: basically, it just strips away the Try part, returning an un-fulfilled Future.

Type parameters

X

the underlying type

Value parameters

xfy

a Future[X] value wrapped in Try

Attributes

Returns

an X value wrapped in Future

def flatten[X](xsfs: Seq[Future[Seq[X]]])(implicit ec: ExecutionContext): Future[Seq[X]]

Type parameters

X

the underlying type

Value parameters

ec

the execution context

xsfs

a sequence of futures, each wrapping a sequence of X

Attributes

Returns

a sequence of X values wrapped in Future NOTE: that the output collection type will be Seq, regardless of the input type

def flatten[K, V](voKm: Map[K, Option[V]]): Map[K, V]
def flattenRecover[X](esf: Future[Seq[Either[Throwable, Seq[X]]]], f: => Throwable => Unit)(implicit executor: ExecutionContext): Future[Seq[X]]

TODO unit test

TODO unit test

Type parameters

X

the underlying type

Value parameters

esf

the collection to process

executor

the executor to use

f

the function to process left-hand-sides

Attributes

Returns

a Future[Seq[X]] NOTE: that the output collection type will be Seq, regardless of the input type

def foldLeftShort[X, Y](xi: Iterator[X], y0: Y, q: Y => Boolean)(f: (Y, X) => Y): Y

This method performs a foldLeft with short-circuit logic

This method performs a foldLeft with short-circuit logic

Type parameters

X

the underlying type of the iterator

Y

the return type

Value parameters

f

the function which accumulates the result: as with foldLeft, it takes a Y and an X and yields a Y

q

the quick-return function: if this evaluates to true, given the new y value, that value is immediately returned

xi

an iterator of X objects

y0

the initial value of Y (e.g. 0 if Y is Int)

Attributes

Returns

the aggregate of the given iterator, according to the initial value of y0 and the accumulator function f.

def invert2[T1, T2, R](f: T1 => T2 => R): T2 => T1 => R

This method inverts the order of the first two parameters of a two-(or more-)parameter curried function.

This method inverts the order of the first two parameters of a two-(or more-)parameter curried function.

Type parameters

R

the result type

T1

the type of the first parameter

T2

the type of the second parameter

Value parameters

f

the function

Attributes

Returns

a curried function which takes the second parameter first

def invert3[T1, T2, T3, R](f: T1 => T2 => T3 => R): T3 => T2 => T1 => R

This method inverts the order of the first three parameters of a three-(or more-)parameter curried function.

This method inverts the order of the first three parameters of a three-(or more-)parameter curried function.

Type parameters

R

the result type

T1

the type of the first parameter

T2

the type of the second parameter

T3

the type of the third parameter

Value parameters

f

the function

Attributes

Returns

a curried function which takes the third parameter first, then the second, etc.

def invert4[T1, T2, T3, T4, R](f: T1 => T2 => T3 => T4 => R): T4 => T3 => T2 => T1 => R

This method inverts the order of the first four parameters of a four-(or more-)parameter curried function.

This method inverts the order of the first four parameters of a four-(or more-)parameter curried function.

Type parameters

R

the result type

T1

the type of the first parameter

T2

the type of the second parameter

T3

the type of the third parameter

T4

the type of the fourth parameter

Value parameters

f

the function

Attributes

Returns

a curried function which takes the fourth parameter first, then the third, etc.

def invert5[T1, T2, T3, T4, T5, R](f: T1 => T2 => T3 => T4 => T5 => R): T5 => T4 => T3 => T2 => T1 => R

This method inverts the order of the first four parameters of a four-(or more-)parameter curried function.

This method inverts the order of the first four parameters of a four-(or more-)parameter curried function.

Type parameters

R

the result type

T1

the type of the first parameter

T2

the type of the second parameter

T3

the type of the third parameter

T4

the type of the fourth parameter

T5

the type of the fifth parameter

Value parameters

f

the function

Attributes

Returns

a curried function which takes the fourth parameter first, then the third, etc.

def invert6[T1, T2, T3, T4, T5, T6, R](f: T1 => T2 => T3 => T4 => T5 => T6 => R): T6 => T5 => T4 => T3 => T2 => T1 => R

This method inverts the order of the first four parameters of a four-(or more-)parameter curried function.

This method inverts the order of the first four parameters of a four-(or more-)parameter curried function.

Type parameters

R

the result type

T1

the type of the first parameter

T2

the type of the second parameter

T3

the type of the third parameter

T4

the type of the fourth parameter

T5

the type of the fifth parameter

T6

the type of the sixth parameter

Value parameters

f

the function

Attributes

Returns

a curried function which takes the fourth parameter first, then the third, etc.

def lift[T, R](f: T => R): Try[T] => Try[R]

Lift function to transform a function f of type T=>R into a function of type Try[T]=>Try[R]

Lift function to transform a function f of type T=>R into a function of type Try[T]=>Try[R]

Type parameters

R

the type of the result of f

T

the type of the parameter to f

Value parameters

f

the function we start with, of type T=>R

Attributes

Returns

a function of type Try[T]=>Try[R]

def lift2[T1, T2, R](f: (T1, T2) => R): (Try[T1], Try[T2]) => Try[R]

Lift function to transform a function f of type (T1,T2)=>R into a function of type (Try[T1],Try[T2])=>Try[R]

Lift function to transform a function f of type (T1,T2)=>R into a function of type (Try[T1],Try[T2])=>Try[R]

Type parameters

R

the type of the result of f

T1

the type of the first parameter to f

T2

the type of the second parameter to f

Value parameters

f

the function we start with, of type (T1,T2)=>R

Attributes

Returns

a function of type (Try[T1],Try[T2])=>Try[R]

def lift2Try[T, U](f: (T, T) => U): (Try[T], Try[T]) => Try[U]

TODO unit test

TODO unit test

A pure lift method to lift a function into Try

Type parameters

T

the underlying source type

U

the underlying result type

Value parameters

f

a function which takes two T parameters and returns a U

Attributes

Returns

the corresponding function which takes to Try[T] parameters and returns a Try[U]

def lift3[T1, T2, T3, R](f: (T1, T2, T3) => R): (Try[T1], Try[T2], Try[T3]) => Try[R]

Lift function to transform a function f of type (T1,T2,T3)=>R into a function of type (Try[T1],Try[T2],Try[T3])=>Try[R]

Lift function to transform a function f of type (T1,T2,T3)=>R into a function of type (Try[T1],Try[T2],Try[T3])=>Try[R]

Type parameters

R

the type of the result of f

T1

the type of the first parameter to f

T2

the type of the second parameter to f

T3

the type of the third parameter to f

Value parameters

f

the function we start with, of type (T1,T2,T3)=>R

Attributes

Returns

a function of type (Try[T1],Try[T2],Try[T3])=>Try[R]

def lift7[T1, T2, T3, T4, T5, T6, T7, R](f: (T1, T2, T3, T4, T5, T6, T7) => R): (Try[T1], Try[T2], Try[T3], Try[T4], Try[T5], Try[T6], Try[T7]) => Try[R]

Lift function to transform a function f of type (T1,T2,T3,T4,T5,T6,T7)=>R into a function of type (Try[T1],Try[T2],Try[T3],Try[T4],Try[T5],Try[T6],Try[T7])=>Try[R]

Lift function to transform a function f of type (T1,T2,T3,T4,T5,T6,T7)=>R into a function of type (Try[T1],Try[T2],Try[T3],Try[T4],Try[T5],Try[T6],Try[T7])=>Try[R]

Type parameters

R

the type of the result of f

T1

the type of the first parameter to f

T2

the type of the second parameter to f

T3

the type of the third parameter to f

T4

the type of the fourth parameter to f

T5

the type of the fifth parameter to f

T6

the type of the sixth parameter to f

T7

the type of the seventh parameter to f

Value parameters

f

the function we start with, of type (T1,T2,T3,T4,T5,T6,T7)=>R

Attributes

Returns

a function of type (Try[T1],Try[T2],Try[T3],Try[T4],Try[T5],Try[T6],Try[T7])=>Try[R]

def liftFuture[T, U](f: T => U)(implicit executor: ExecutionContext): Future[T] => Future[U]

TODO unit test

TODO unit test

A pure lift method to lift a function into Future

Type parameters

T

the underlying source type

U

the underlying result type

Value parameters

executor

(implicit) execution context

f

a function which takes two T parameters and returns a U

Attributes

Returns

the corresponding function which takes to Future[T] parameters and returns a Future[U]

def liftOption[T, U](f: T => U): Option[T] => Option[U]

TODO unit test

TODO unit test

A pure lift method to lift a function into Option

Type parameters

T

the underlying source type

U

the underlying result type

Value parameters

f

a function which takes two T parameters and returns a U

Attributes

Returns

the corresponding function which takes to Option[T] parameters and returns an Option[U]

def liftOptionTry[T, U](f: T => U)(implicit ex: Throwable = ...): Option[T] => Try[U]

A true "lift" method which takes a function f (T=>U) and returns an Option[T]=>Try[T] This is a bit of an odd-ball function, not frequently used.

A true "lift" method which takes a function f (T=>U) and returns an Option[T]=>Try[T] This is a bit of an odd-ball function, not frequently used.

Type parameters

T

the T type

U

the U type

Value parameters

f

a function which transforms an T into a U

Attributes

Returns

the corresponding function which takes an Option[T] and returns a Try[U]

def liftTry[T, U](f: T => U): Try[T] => Try[U]

TODO unit test

TODO unit test

A true "lift" method which takes a function f (T=>U) and returns a Try[T]=>Try[T]

Type parameters

T

the T type

U

the U type

Value parameters

f

a function which transforms an T into a U

Attributes

Returns

the corresponding function which takes a Try[T] and returns a Try[U]

def logFailure[X](xy: => Try[X], f: Throwable => Unit): Try[X]

This method simply returns xy if it is a Success. If it's a Failure, then it will invoke function f, as a side-effect, and then return the failure but with a standard message. If the cause is fatal, then it will be thrown.

This method simply returns xy if it is a Success. If it's a Failure, then it will invoke function f, as a side-effect, and then return the failure but with a standard message. If the cause is fatal, then it will be thrown.

Similar to recover, recoverWith, etc.

Type parameters

X

the underlying type of the return

Value parameters

f

the function to process the cause of any failure

xy

the Try[X] that is passed in (call-by-name)

Attributes

Returns

a Try[X]

def map2[T1, T2, R](t1o: Option[T1], t2o: => Option[T2])(f: (T1, T2) => R): Option[R]

method to map a pair of Option values (of same underlying type) into an Option value of another type (which could be the same of course)

method to map a pair of Option values (of same underlying type) into an Option value of another type (which could be the same of course)

Type parameters

R

the result type

T1

the underlying type of the first parameter

Value parameters

f

function which takes a T1 and a T2 parameter and yields a R result

t1o

a Option[T1] value

t2o

a Option[T2] value

Attributes

Returns

a Option[U]

def map2[T1, T2, R](t1y: Try[T1], t2y: Try[T2])(f: (T1, T2) => R): Try[R]

The map2 function.

The map2 function.

Type parameters

R

the type of the result of function f

T1

the type of parameter 1

T2

the type of parameter 2

Value parameters

f

function that takes two parameters of types T1 and T2 and returns a value of R

t1y

parameter 1 wrapped in Try

t2y

parameter 2 wrapped in Try

Attributes

Returns

a value of R, wrapped in Try

def map2g[T1, T2, R](t1o: Option[T1], t2o: => Option[T2])(f: (T1, T2) => R, g: (T1, T2) => Boolean): Option[R]

method to map a pair of Option values (of same underlying type) into an Option value of another type (which could be the same of course) but with an additional guard function. If the guard function returns false, the f function will not be called and None will result.

method to map a pair of Option values (of same underlying type) into an Option value of another type (which could be the same of course) but with an additional guard function. If the guard function returns false, the f function will not be called and None will result.

Type parameters

R

the result type

T1

the underlying type of the first parameter

Value parameters

f

function which takes a T1 and a T2 parameter and yields a R result

g

guard function which takes a T1 and a T2 parameter and yields a Boolean result

t1o

a Option[T1] value

t2o

a Option[T2] value

Attributes

Returns

a Option[U]

def map2lazy[T, U](ty1: Try[T], ty2: => Try[T])(f: (T, T) => U)(implicit g: T => Boolean = ..., default: Try[U] = ...): Try[U]

TODO unit test

TODO unit test

NOTE: not available with 2.10

method to map a pair of Try values (of same underlying type) into a Try value of another type (which could be the same of course)

Type parameters

T

the input type

U

the result type

Value parameters

default

(implicit) a default value

f

function which takes two T parameters and yields a U result

g

(implicit) guard function which, given the first parameter's value, must be true for the second parameter (ty2) to be evaluated

ty1

a Try[T] value

ty2

a Try[T] value passed as call-by-name

Attributes

Returns

a Try[U]

def map3[T1, T2, T3, R](t1y: Option[T1], t2y: Option[T2], t3y: Option[T3])(f: (T1, T2, T3) => R): Option[R]

The map3 function. Much like map2

The map3 function. Much like map2

Type parameters

R

the type of the result of function f

T1

the type of parameter 1

T2

the type of parameter 2

T3

the type of parameter 3

Value parameters

f

function that takes three parameters of types T1, T2 and T3 and returns a value of R

t1y

parameter 1 wrapped in Option

t2y

parameter 2 wrapped in Option

t3y

parameter 3 wrapped in Option

Attributes

Returns

a value of R, wrapped in Try

def map3[T1, T2, T3, R](t1y: Try[T1], t2y: Try[T2], t3y: Try[T3])(f: (T1, T2, T3) => R): Try[R]

The map3 function. Much like map2

The map3 function. Much like map2

Type parameters

R

the type of the result of function f

T1

the type of parameter 1

T2

the type of parameter 2

T3

the type of parameter 3

Value parameters

f

function that takes three parameters of types T1, T2 and T3 and returns a value of R

t1y

parameter 1 wrapped in Try

t2y

parameter 2 wrapped in Try

t3y

parameter 3 wrapped in Try

Attributes

Returns

a value of R, wrapped in Try

def map3lazy[T, U](ty1: Try[T], ty2: => Try[T], ty3: => Try[T])(f: (T, T, T) => U)(implicit g: T => Boolean = ..., default: Try[U] = ...): Try[U]

NOTE: not available with 2.10

NOTE: not available with 2.10

method to map a pair of Try values (of same underlying type) into a Try value of another type (which could be the same of course)

Type parameters

T

the input type

U

the result type

Value parameters

default

(implicit) a default value

f

function which takes two T parameters and yields a U result

g

(implicit) guard function which, given the first parameter's value, must be true for the second parameter (ty2) to be evaluated; and which, given the second parameter's value, must be true for the third parameter (ty3) to be evaluated

ty1

a Try[T] value

ty2

a Try[T] value passed as call-by-name

ty3

a Try[T] value passed as call-by-name

Attributes

Returns

a Try[U]

def map7[T1, T2, T3, T4, T5, T6, T7, R](t1y: Try[T1], t2y: Try[T2], t3y: Try[T3], t4y: Try[T4], t5y: Try[T5], t6y: Try[T6], t7y: Try[T7])(f: (T1, T2, T3, T4, T5, T6, T7) => R): Try[R]

You get the idea...

You get the idea...

Attributes

def named[T, R](name: String, f: T => R): T => R

TODO unit test

TODO unit test

Type parameters

R

the underlying result type

T

the underlying source type

Value parameters

f

a function which transforms a T into an R

Attributes

Returns

a named function which takes a T and returns an R

def nextOption[X](xi: Iterator[X]): Option[X]

Method to get the next element from an iterator, as an Option.

Method to get the next element from an iterator, as an Option.

Type parameters

X

the underlying type.

Value parameters

xi

the iterator.

Attributes

Returns

Some(x) where x is the next element; or None where the iterator is exhausted.

def optionToTry[X](xo: Option[X], t: => Throwable): Try[X]

Convert an Option[X] into a Try[X], given an explicit throwable for the None case

Convert an Option[X] into a Try[X], given an explicit throwable for the None case

Type parameters

X

the underlying type of the input and the output

Value parameters

t

a throwable which, wrapped in Failure, will be returned if xo is None

xo

an X value wrapped in Option

Attributes

Returns

an X value wrapped as a Try

def optionToTry[X](xo: Option[X]): Try[X]

Convert an Option[X] into a Try[X], using the default throwable for the None case

Convert an Option[X] into a Try[X], using the default throwable for the None case

Type parameters

X

the underlying type of the input and the output

Value parameters

xo

an X value wrapped in Option

Attributes

Returns

an X value wrapped as a Try. If xo is None, then the result will be a NoSuchElementException wrapped in Failure

def recoverWith[X](xys: Seq[Try[X]], t: Throwable = ...): Seq[Try[X]]

Perform recover on a sequence of Try objects.

Perform recover on a sequence of Try objects.

Type parameters

X

the underlying type of the tries

Value parameters

t

the Throwable to replace the nonfatal throwable already reported.

xys

the sequence of tries

Attributes

Returns

xys essentially unchanged though with the side-effect of having written any non-fatal exceptions to the console and all non-fatal failures replaced by Failure(t) NOTE: that the output collection type will be Seq, regardless of the input type

def renderLimited[A](as: => Seq[A])(implicit limit: Int = ...): String

TODO unit test

TODO unit test

Type parameters

A

the underlying type of the sequence

Value parameters

as

a sequence of As

limit

the limit of how many you want to show

Attributes

Returns

a String representing the first "limit" elements of as

def sequence[X](xy: => Try[X]): Either[Throwable, X]

TODO unit test

TODO unit test

Type parameters

X

the underlying type

Value parameters

xy

a Try[X] value

Attributes

Returns

Right[X] if successful, else a Left[X]

def sequence[X](xf: Future[X])(implicit executor: ExecutionContext): Future[Either[Throwable, X]]

Transform a Future[X] into a Future of Either[Throwable,X]

Transform a Future[X] into a Future of Either[Throwable,X]

Type parameters

X

the underlying type

Value parameters

executor

an execution context

xf

a Future[X]

Attributes

Returns

a Future of Either[Throwable, X]

def sequence[X](xfs: Seq[Future[X]])(implicit executor: ExecutionContext): Seq[Future[Either[Throwable, X]]]

Type parameters

X

the underlying type

Value parameters

executor

an execution context

xfs

a sequence of Future[X]

Attributes

Returns

a Seq of Future of Either[Throwable, X] NOTE: that the output collection type will be Seq, regardless of the input type

def sequence[X](xys: Seq[Try[X]]): Try[Seq[X]]

Type parameters

X

the underlying type

Value parameters

xys

a sequence of Try[X]

Attributes

Returns

a Try of Seq[X] NOTE: that the output collection type will be Seq, regardless of the input type

def sequence[X](xys: Stream[Try[X]]): Try[Stream[X]]

TODO unit test

TODO unit test

Type parameters

X

the underlying type

Value parameters

xys

a Stream of Try[X] values

Attributes

Returns

a Stream[X] wrapped in a Try

def sequence[X](xos: Seq[Option[X]]): Option[Seq[X]]

TODO unit test

TODO unit test

Type parameters

X

the underlying type

Value parameters

xos

a sequence of Option[X] values

Attributes

Returns

a sequence of X values wrapped in Option NOTE: that the output collection type will be Seq, regardless of the input type

def sequence[X](xe: Either[Throwable, X]): Option[X]

TODO unit test

TODO unit test

Type parameters

X

the underlying type

Value parameters

xe

an Either[Throwable,X] object

Attributes

Returns

an X value wrapped inside Option

def toMap[K, V](vKs: Seq[(K, V)]): Map[K, V]

Method to create an (immutable) Map from a sequence of tuples, such that order is preserved

Method to create an (immutable) Map from a sequence of tuples, such that order is preserved

Type parameters

K

the underlying "key" type

V

the underlying "value" type

Value parameters

vKs

a sequence of (K,V) tuples

Attributes

Returns

a ListMap[K,V]

def toOption[X](xy: Try[X], fLog: Throwable => Unit = ...): Option[X]

Alternative to the toOption method in Option which, in my humble opinion, is dangerous because it's just too easy to lose failures. This method will throw any fatal failures, log any non-fatal failures and then convert the Try to an Option

Alternative to the toOption method in Option which, in my humble opinion, is dangerous because it's just too easy to lose failures. This method will throw any fatal failures, log any non-fatal failures and then convert the Try to an Option

Type parameters

X

the underlying type of Try

Value parameters

xy

the Try object

Attributes

Returns

an Option which is Some(x) for Success(x) and None for Failure(t) where x has been handled as a side-effect

def toOption[X](b: Boolean, x: X): Option[X]

Method to convert a b into an Option[X]

Method to convert a b into an Option[X]

Type parameters

X

the underlying type

Value parameters

b

a Boolean value

x

an X value

Attributes

Returns

if b is true then Some(x) else None

def toOption[X](p: X => Boolean)(t: X): Option[X]

Method to yield an Option[X] value based on a X-predicate and an X value.

Method to yield an Option[X] value based on a X-predicate and an X value.

Type parameters

X

the underlying type of the value and the resulting Option

Value parameters

p

the predicate

t

the value to wrap in Some if the predicate is satisfied

Attributes

Returns

Option[X]

def trial[X, Y](f: X => Y)(x: => X): Try[Y]

TODO unit test

TODO unit test

Type parameters

X

the input type of f

Y

the output type of f

Value parameters

f

a function which transforms an X into a Y

x

an X value

Attributes

Returns

a Try[Y]

def uncurried2[T1, T2, T3, R](f: T1 => T2 => T3 => R): (T1, T2) => T3 => R

This method uncurries the first two parameters of a three- (or more-) parameter curried function. The result is a (curried) function whose first parameter is a tuple of the first two parameters of f; whose second parameter is the third parameter, etc.

This method uncurries the first two parameters of a three- (or more-) parameter curried function. The result is a (curried) function whose first parameter is a tuple of the first two parameters of f; whose second parameter is the third parameter, etc.

Type parameters

R

the result type of function f

T1

the type of the first parameter

T2

the type of the second parameter

T3

the type of the third parameter

Value parameters

f

the function

Attributes

Returns

a (curried) function of type (T1,T2)=>T4=>R

def uncurried3[T1, T2, T3, T4, R](f: T1 => T2 => T3 => T4 => R): (T1, T2, T3) => T4 => R

This method uncurries the first three parameters of a four- (or more-) parameter curried function. The result is a (curried) function whose first parameter is a tuple of the first three parameters of f; whose second parameter is the third parameter, etc.

This method uncurries the first three parameters of a four- (or more-) parameter curried function. The result is a (curried) function whose first parameter is a tuple of the first three parameters of f; whose second parameter is the third parameter, etc.

Type parameters

R

the result type of function f

T1

the type of the first parameter

T2

the type of the second parameter

T3

the type of the third parameter

T4

the type of the fourth parameter

Value parameters

f

the function

Attributes

Returns

a (curried) function of type (T1,T2,T3)=>T4=>R

def uncurried7[T1, T2, T3, T4, T5, T6, T7, T8, R](f: T1 => T2 => T3 => T4 => T5 => T6 => T7 => T8 => R): (T1, T2, T3, T4, T5, T6, T7) => T8 => R

This method uncurries the first three parameters of a four- (or more-) parameter curried function. The result is a (curried) function whose first parameter is a tuple of the first seven parameters of f; whose second parameter is the third parameter, etc.

This method uncurries the first three parameters of a four- (or more-) parameter curried function. The result is a (curried) function whose first parameter is a tuple of the first seven parameters of f; whose second parameter is the third parameter, etc.

Type parameters

R

the result type of function f

T1

the type of the first parameter

T2

the type of the second parameter

T3

the type of the third parameter

T4

the type of the fourth parameter

Value parameters

f

the function

Attributes

Returns

a (curried) function of type (T1,T2,T3)=>T4=>R

def untupled[T1, T2, R](f: ((T1, T2)) => R): (T1, T2) => R

This method (and the following similar methods) are missing from Function (or at least, the method in Function is flaky)

This method (and the following similar methods) are missing from Function (or at least, the method in Function is flaky)

Type parameters

R

the result type

T1

the first parameter type

T2

the second parameter type

Value parameters

f

the function to be untupled

Attributes

Returns

a function which takes the parameters separately (as part of a parameter set)

def untupled[T1, T2, T3, R](f: ((T1, T2, T3)) => R): (T1, T2, T3) => R

This method (and the following similar methods) are missing from Function (or at least, the method in Function is flaky)

This method (and the following similar methods) are missing from Function (or at least, the method in Function is flaky)

Type parameters

R

the result type

T1

the first parameter type

T2

the second parameter type

T3

the third parameter type

Value parameters

f

the function to be untupled

Attributes

Returns

a function which takes the parameters separately (as part of a parameter set)

def untupled[T1, T2, T3, T4, R](f: ((T1, T2, T3, T4)) => R): (T1, T2, T3, T4) => R

This method (and the following similar methods) are missing from Function (or at least, the method in Function is flaky)

This method (and the following similar methods) are missing from Function (or at least, the method in Function is flaky)

Type parameters

R

the result type

T1

the first parameter type

T2

the second parameter type

T3

the third parameter type

T4

the fourth parameter type

Value parameters

f

the function to be untupled

Attributes

Returns

a function which takes the parameters separately (as part of a parameter set)

def untupled[T1, T2, T3, T4, T5, R](f: ((T1, T2, T3, T4, T5)) => R): (T1, T2, T3, T4, T5) => R

This method (and the following similar methods) are missing from Function

This method (and the following similar methods) are missing from Function

Type parameters

R

the result type

T1

the first parameter type

T2

the second parameter type

T3

the third parameter type

T4

the fourth parameter type

T5

the fifth parameter type

Value parameters

f

the function to be untupled

Attributes

Returns

a function which takes the parameters separately (as part of a parameter set)

def untupled[T1, T2, T3, T4, T5, T6, R](f: ((T1, T2, T3, T4, T5, T6)) => R): (T1, T2, T3, T4, T5, T6) => R

This method (and the following similar methods) are missing from Function

This method (and the following similar methods) are missing from Function

Type parameters

R

the result type

T1

the first parameter type

T2

the second parameter type

T3

the third parameter type

T4

the fourth parameter type

T5

the fifth parameter type

T6

the sixth parameter type

Value parameters

f

the function to be untupled

Attributes

Returns

a function which takes the parameters separately (as part of a parameter set)

def untupled[T1, T2, T3, T4, T5, T6, T7, R](f: ((T1, T2, T3, T4, T5, T6, T7)) => R): (T1, T2, T3, T4, T5, T6, T7) => R

This method (and the following similar methods) are missing from Function

This method (and the following similar methods) are missing from Function

Type parameters

R

the result type

T1

the first parameter type

T2

the second parameter type

T3

the third parameter type

T4

the fourth parameter type

T5

the fifth parameter type

T6

the sixth parameter type

T7

the seventh parameter type

Value parameters

f

the function to be untupled

Attributes

Returns

a function which takes the parameters separately (as part of a parameter set)

def which[T](b: Boolean)(t: (T, T)): T

Method to select an element from a tuple according to a Boolean value. You may invoke this method either as which(b)(x,y) or which (b)((x,y))

Method to select an element from a tuple according to a Boolean value. You may invoke this method either as which(b)(x,y) or which (b)((x,y))

Type parameters

T

the underlying type

Value parameters

b

a boolean

t

a tuple

Attributes

Returns

the first element of the tuple if b is true, else the second element

def zip[A, B](ao: Option[A], bo: Option[B]): Option[(A, B)]

TODO unit test zip two options into an option of a tuple

TODO unit test zip two options into an option of a tuple

Type parameters

A

the underlying type of the first parameter

B

the underlying type of the second parameter

Value parameters

ao

an A wrapped inside Option

bo

a B wrapped inside Option

Attributes

Returns

a tuple containing an A and a B value, all wrapped inside Option

def zip[A, B](ao: Try[A], bo: Try[B]): Try[(A, B)]

TODO unit test zip two try values into a Try of a tuple

TODO unit test zip two try values into a Try of a tuple

Type parameters

A

the underlying type of the first parameter

B

the underlying type of the second parameter

Value parameters

ao

an A wrapped inside Try

bo

a B wrapped inside Try

Attributes

Returns

a tuple containing an A and a B value, all wrapped inside Try

def zip[A, B](af: Future[A], bf: Future[B])(implicit ec: ExecutionContext): Future[(A, B)]

TODO unit test zip two Future values into a Future of a tuple

TODO unit test zip two Future values into a Future of a tuple

Type parameters

A

the underlying type of the first parameter

B

the underlying type of the second parameter

Value parameters

af

an A wrapped inside Future

bf

a B wrapped inside Future

Attributes

Returns

a tuple containing an A and a B value, all wrapped inside Future

def zippy[A, B](as: Iterable[A], bs: Iterable[B]): (Iterable[(A, B)], Iterable[A], Iterable[B])

Method to zip two iterables together but in such a way that all elements are returned in one or other of the components of the result

Method to zip two iterables together but in such a way that all elements are returned in one or other of the components of the result

Type parameters

A

the underlying type of as

B

the underlying type of bs

Value parameters

as

a iterable of As

bs

a iterable of Bs

Attributes

Returns

a Tuple3 which contains: the zip of as and bs; the remaining elements of as (if any); the remaining elements of bs (if any)

Implicits

Implicits

implicit val limit: Int