A bijective function between values of two types T
and S
.
A bijective function between values of two types T
and S
.
A bijection maps every element of type T
into exactly one
element of type S
, and every element of type S
into exactly
one element of type T
.
It is a function and its inverse bundled together.
Additionally, it has the property that b.inv(b.apply(x)) == x
and b.apply(b.inv(x)) == x
.
Note: Bijection is specialized. Boxing is avoided for primitive values if both the source type and the target type are integers, longs or doubles.
An injective function between values of two types T
and S
.
An injective function between values of two types T
and S
.
In mathematics, an injection maps elements of type T
into exactly one
element of type S
, and can map some elements of type S
into
one element of type T
.
An injection is undefined for some values in S
.
Here, an injection may also be undefined for some elements in T
.
An injection is a partial function and its partial inverse bundled together.
For example, a mapping from natural numbers to twice their value
forms an injection 1 -> 2
, 2 -> 4
, 3 -> 6
and so on.
The inverse is not defined for every natural number --
2
is mapped to 1
, but 3
is not mapped to anything.
Additionally, it has the property that b.inv(b.apply(x)) == x
.
If b.inv
is defined for x
, then b.apply(b.inv(x)) == x
.
Note:
Injection
is not specialized, and neither is the standard library
PartialFunction
class.
Reactive random value.
Reactive random value.
It can be used as a regular random generator that produces random values:
val r = new ReactRandom(1L) r.double()
Or, as a reactive random value, by subscribing to events produced when emit
is called:
val evens = r.react.int().filter(_ % 2 == 0)
Above, evens
contains random values.
Contains factory methods for bijection instances.
Contains factory methods for injection instances.