Other Functions
The following functions are available globally.
-
Declaration
Swift
public func cartesianProduct <T,U> (_ a: T, _ b: U) -> [(T.Element, U.Element)] where T: Sequence, U: Sequence
Return Value
Cartesian product of two sequences.
-
let (lower,higher) = ordered(7,3) // => (3,7)
Note
If both values are equal, they are returned in the order in which they were given
Declaration
Swift
public func ordered<T>(_ a: T, _ b: T) -> (T, T) where T : Comparable
Return Value
2-tuple of two given values, in order.
-
Applies the given transform
f
to the given valuesa
andb
.Declaration
Swift
public func map<T, U>(_ a: T, _ b: T, _ f: (T) -> U) -> (U, U)
-
Applies the given transform
f
to the given valuesa
andb
,c
.Declaration
Swift
public func map<T, U>(_ a: T, _ b: T, _ c: T, _ f: (T) -> U) -> (U, U, U)
-
Applies the given transform
f
to each value of the given tuplevalues
.Declaration
Swift
public func map<T, U>(_ values: (T, T), _ f: (T) -> U) -> (U, U)
-
Applies the given transform
f
to each value of the given tuplevalues
.Declaration
Swift
public func map<T, U>(_ values: (T, T, T), _ f: (T) -> U) -> (U, U, U)