Docs (85% documented)

Reference Functions Reference

Functions

The following functions are available globally.

  • A Bool indicating whether the predicate condition holds for some element in sequence

    Declaration

    Swift

    public func any<S: SequenceType>(sequence: S, condition: S.Generator.Element -> BooleanType) -> Bool

    Parameters

    sequence

    A value of type that confirms to SequenceType protocol

    condition

    condition for element of sequence

    Return Value

    whether condition holds for some element in sequence

  • A Bool indicating whether the predicate condition holds for all element in sequence

    Declaration

    Swift

    public func all<S: SequenceType>(sequence: S, condition: S.Generator.Element -> BooleanType) -> Bool

    Parameters

    sequence

    A value of type that confirms to SequenceType protocol

    condition

    condition for element of sequence

    Return Value

    whether condition holds for all element in sequence

  • Insert element between elements of sequence

    Declaration

    Swift

    public func intersperse<S: SequenceType>(sequence: S, element: S.Generator.Element) -> [S.Generator.Element]

    Parameters

    sequence

    Sequence type

    element

    Sequence’s element type

    Return Value

    The result of the interspersion of element between sequence elements

  • Array of all subsequences from sequence

    Declaration

    Swift

    public func subsequences<S: SequenceType>(sequence: S) -> [[S.Generator.Element]]

    Parameters

    sequence

    Sequence type

    Return Value

    All subsequences for sequence type argument

  • Array from intermediate to final results of reduce function

    Declaration

    Swift

    public func scan<S: SequenceType, U>(sequence: S, initial: U, combine: (U, S.Generator.Element) -> U) -> [U]

    Parameters

    sequence

    Sequence type

    initial

    initial for reduce

    combine

    combine function for reduce

    Return Value

    Array of reduce results

  • Array of flattened result of sequences transformed from sequence’s elements

    Declaration

    Swift

    public func flatMap<S: SequenceType, T: SequenceType>(sequence: S, transform: S.Generator.Element -> T) -> [T.Generator.Element]

    Parameters

    sequence

    Sequence type

    transform

    transform for elenemt of sequence to other sequence

    Return Value

    Array of other sequence element

  • Takes a sequence and returns a array of array such that the concatenation of the result for condition holds to the argument

    Declaration

    Swift

    public func groupBy<S: SequenceType>(sequence: S, condition: (S.Generator.Element , S.Generator.Element) -> Bool) -> [[S.Generator.Element]]

    Parameters

    sequence

    Sequence type

    condition

    condition for elements

    Return Value

    Array of sequence element’s array

  • Extract the elements after the first of a sequence

    Declaration

    Swift

    public func tail<S: SequenceType>(sequence: S) -> [S.Generator.Element]

    Parameters

    sequence

    Sequence type

    Return Value

    Array of Sequence Element Type

  • All the elements of a sequence except the last one

    Declaration

    Swift

    public func rtail<S: SequenceType>(sequence: S) -> [S.Generator.Element]

    Parameters

    sequence

    Sequence type

    Return Value

    Array of Sequence Element Type

  • All final segments of the argument, longest first

    Declaration

    Swift

    public func tails<S: SequenceType>(sequence: S) -> [[S.Generator.Element]]

    Parameters

    sequence

    Sequence type

    Return Value

    Array of array of Sequence Element Type

  • All initial segments of the argument, shortest first

    Declaration

    Swift

    public func rtails<S: SequenceType>(sequence: S) -> [[S.Generator.Element]]

    Parameters

    sequence

    Sequence type

    Return Value

    Array of array of Sequence Element Type

  • Longest prefix of sequence type satisfying the condition

    Declaration

    Swift

    public func takeWhile<S: SequenceType>(sequence: S, condition: S.Generator.Element -> BooleanType) -> [S.Generator.Element]

    Parameters

    sequence

    Sequence type

    condition

    condition for element

    Return Value

    Array of Sequence Element Type

  • Suffix of sequence type remaining after takeWhile

    Declaration

    Swift

    public func dropWhile<S: SequenceType>(sequence: S, condition: S.Generator.Element -> BooleanType) -> [S.Generator.Element]

    Parameters

    sequence

    Sequence type

    condition

    condition for element

    Return Value

    Array of Sequence Element Type

  • Tuple where first element is longest prefix of sequence type satisfying the condition and second element is the remainder of the list

    Declaration

    Swift

    public func span<S: SequenceType>(sequence: S, condition: S.Generator.Element -> BooleanType) -> ([S.Generator.Element], [S.Generator.Element])

    Parameters

    sequence

    Sequence type

    condition

    condition for element

    Return Value

    Tuple of Array of Sequence Element Type

  • A safe casted array for type U applied to Sequence Type

    Declaration

    Swift

    public func cast<S: SequenceType, U>(sequence: S!, forType: U.Type) -> [U]?

    Parameters

    sequence

    Sequence type (implicitly unwrapped optional)

    forType

    U Type to cast

    Return Value

    optional [U]

  • Takes a sequence and returns a array of array such that the concatenation of the result is equal to the argument

    Declaration

    Swift

    public func group<S: SequenceType where S.Generator.Element: Equatable>(sequence: S) -> [[S.Generator.Element]]

    Parameters

    sequence

    Sequence type

    Return Value

    Array of sequence element’s array

  • Drops the given prefix from sequence

    Declaration

    Swift

    public func stripPrefix<S: SequenceType where S.Generator.Element: Equatable>(sequence: S, prefix: S) -> [S.Generator.Element]?

    Parameters

    sequence

    Sequence type

    prefix

    Sequence type prefix

    Return Value

    Optional.None if the sequence did not start with the prefix given , or Optional.Some the sequence after the prefix if it does

  • Removes duplicate elements from a sequence

    Declaration

    Swift

    public func distinct<S: SequenceType where S.Generator.Element: Equatable>(sequence: S) -> [S.Generator.Element]

    Parameters

    sequence

    Sequence type

    Return Value

    Array without duplicate element

  • Union of the two sequences in which duplicate elements are removed

    Declaration

    Swift

    public func union<S: SequenceType where S.Generator.Element: Equatable>(sequence1: S, sequence2: S) -> [S.Generator.Element]

    Parameters

    sequence1

    Sequence type

    sequence2

    Sequence type

    Return Value

    Union of the two sequences

  • Intersection of the two sequences. If the first sequence contains duplicate, so will the return value

    Declaration

    Swift

    public func intersect<S: SequenceType where S.Generator.Element: Equatable>(sequence1: S, sequence2: S) -> [S.Generator.Element]

    Parameters

    sequence1

    Sequence type

    sequence2

    Sequence type

    Return Value

    Intersection of the two sequences

  • Equal operator for Sequence type

    Declaration

    Swift

    public func == <S1 : SequenceType, S2 : SequenceType where S1.Generator.Element == S2.Generator.Element, S1.Generator.Element : Equatable>(lhs: S1, rhs: S2) -> Bool

    Parameters

    lhs

    left Sequence Type

    rhs

    right Sequence Type

    Return Value

    whether lhs & rhs contains same elements in the same order

  • A Bool indicating the existance for some element in array

    Declaration

    Swift

    public func existsAny<T>(array: [T?]) -> Bool

    Parameters

    array

    Array of optional type

    Return Value

    the existance for some element in array

  • A Bool indicating the existance for all element in array

    Declaration

    Swift

    public func existsAll<T>(array: [T?]) -> Bool

    Parameters

    array

    Array of optional type

    Return Value

    the existance for all element in array

  • Array of concatenation for a array of array type

    Declaration

    Swift

    public func concat<U>(array: [[U]]) -> [U]

    Parameters

    array

    array of array type

    Return Value

    Array of concatenation

  • The Index of the first element in the collection type satisfying the condition

    Declaration

    Swift

    public func findIndex<C: CollectionType>(collection: C, condition: C.Generator.Element -> BooleanType) -> C.Index?

    Parameters

    collection

    Collection type

    condition

    condition for element

    Return Value

    The first index (Optional)

  • Prefix of collection from first to index element

    Declaration

    Swift

    public func take<C: CollectionType>(collection: C, index: C.Index) -> [C.Generator.Element]

    Parameters

    collection

    Collection type

    index

    index for element

    Return Value

    Array of Collection Element Type

  • Suffix of collection from index to last element

    Declaration

    Swift

    public func drop<C: CollectionType>(collection: C, index: C.Index) -> [C.Generator.Element]

    Parameters

    collection

    Collection type

    index

    index for element

    Return Value

    Array of Collection Element Type

  • Tuple where first element is Prefix of collection from first to index element and second element is the remainder

    Declaration

    Swift

    public func splitAt<C: CollectionType>(collection: C, index: C.Index) -> ([C.Generator.Element], [C.Generator.Element])

    Parameters

    collection

    Collection type

    index

    index for element

    Return Value

    Tuple of Array of Collection Element Type

  • Sum for Sequence type of IntegerArithmeticType Elements

    Declaration

    Swift

    public func sum<S: SequenceType where S.Generator.Element: IntegerArithmeticType>(sequence: S) -> S.Generator.Element

    Parameters

    sequence

    Sequence type of IntegerArithmeticType Elements

    Return Value

    sum of elements

  • Product for Sequence type of IntegerArithmeticType Elements

    Declaration

    Swift

    public func product<S: SequenceType where S.Generator.Element: IntegerArithmeticType>(sequence: S) -> S.Generator.Element

    Parameters

    sequence

    Sequence type of IntegerArithmeticType Elements

    Return Value

    product of elements

  • Sum for Sequence type of FloatingArithmeticType Elements

    Declaration

    Swift

    public func sum<S: SequenceType where S.Generator.Element: FloatingArithmeticType>(sequence: S) -> S.Generator.Element

    Parameters

    sequence

    Sequence type of FloatingArithmeticType Elements

    Return Value

    sum of elements

  • Product for Sequence type of FloatingArithmeticType Elements

    Declaration

    Swift

    public func product<S: SequenceType where S.Generator.Element: FloatingArithmeticType>(sequence: S) -> S.Generator.Element

    Parameters

    sequence

    Sequence type of FloatingArithmeticType Elements

    Return Value

    product of elements

  • Conjunction of a BooleanType sequence

    Declaration

    Swift

    public func and<S: SequenceType where S.Generator.Element: BooleanType>(sequence: S) -> Bool

    Parameters

    sequence

    BooleanType sequence

    Return Value

    whether all elements are true

  • Disjunction of a BooleanType sequence

    Declaration

    Swift

    public func or<S: SequenceType where S.Generator.Element: BooleanType>(sequence: S) -> Bool

    Parameters

    sequence

    BooleanType sequence

    Return Value

    whether at least one of the elements is true