Functions

The following functions are available globally.

  • Returns an array of two sequences interdigitated “`swift interdig([1, 2, 3], [10, 20, 30])

    [1, 10, 2, 20, 3, 30] ”`

    Declaration

    Swift

    public func interdig<
      S0 : SequenceType, S1 : SequenceType where
      S0.Generator.Element == S1.Generator.Element
      >(s0: S0, _ s1: S1) -> [S0.Generator.Element]
  • Returns an array of two sequences interdigitated, with the respective length of each interdigitation specified - Parameter s0Len: The length of the first sequence’s interdigitations - Parameter s1Len: The length of the second sequence’s interdigitations “`swift interdig([1, 2, 3, 4, 5], [10, 20, 30, 40, 50, 60], s0Len: 2, s1Len: 3)

    [1, 2, 10, 20, 30, 3, 4, 40, 50, 60, 5] ”`

    Declaration

    Swift

    public func interdig<
      S0 : SequenceType, S1 : SequenceType where
      S0.Generator.Element == S1.Generator.Element
      >(s0: S0, _ s1: S1, s0Len: Int, s1Len: Int) -> [S0.Generator.Element]

    Parameters

    s0Len

    The length of the first sequence’s interdigitations

    s1Len

    The length of the second sequence’s interdigitations

  • Returns a lazy sequence of two sequences interdigitated “`swift interdig([1, 2, 3].lazy, [10, 20, 30].lazy)

    1, 10, 2, 20, 3, 30 ”`

    Declaration

    Swift

    public func interdig<
      S0 : LazySequenceType, S1 : LazySequenceType where
      S0.Generator.Element == S1.Generator.Element
      >(s0: S0, _ s1: S1) -> InterDigSeq<S0, S1>
  • Returns a lazy sequence of two sequences interdigitated, with the respective length of each interdigitation specified - Parameter s0Len: The length of the first sequence’s interdigitations - Parameter s1Len: The length of the second sequence’s interdigitations “`swift interdig([1, 2, 3, 4, 5].lazy, [10, 20, 30, 40, 50, 60].lazy, s0Len: 2, s1Len: 3)

    1, 2, 10, 20, 30, 3, 4, 40, 50, 60, 5 ”`

    Declaration

    Swift

    public func interdig<
      S0 : SequenceType, S1 : SequenceType where
      S0.Generator.Element == S1.Generator.Element
      >(s0: S0, _ s1: S1, s0Len: Int, s1Len: Int = 1) -> InterDigSeq<S0, S1>

    Parameters

    s0Len

    The length of the first sequence’s interdigitations

    s1Len

    The length of the second sequence’s interdigitations

  • Cartesian product swift product([1, 2], [3, 4]) [[1, 3], [1, 4], [2, 3], [2, 4]]

    Declaration

    Swift

    public func product<C : CollectionType>(cols: C...) -> [[C.Generator.Element]]
  • Cartesian product swift product([1, 2], [3, 4]) [[1, 3], [1, 4], [2, 3], [2, 4]]

    Declaration

    Swift

    public func product<S : SequenceType>(cols: S...) -> [[S.Generator.Element]]
  • Lazy Cartesian Product “`swift lazyProduct([1, 2], [3, 4])

    [1, 3], [1, 4], [2, 3], [2, 4] ”`

    Declaration

    Swift

    public func lazyProduct<C : CollectionType>
      (cols: C...) -> ProdSeq<C>
  • Lazy Cartesian Product “`swift lazyProduct([1, 2], [3, 4])

    [1, 3], [1, 4], [2, 3], [2, 4] ”`

    Declaration

    Swift

    public func lazyProduct<S : SequenceType>
      (cols: S...) -> ProdSeq<[S.Generator.Element]>
  • A sequence of pairs built out of two underlying sequences, where the elements of the ith pair are optional ith elements of each underlying sequence. If one sequence is shorter than the other, pairs will continue to be returned after it is exhausted, but with its elements replaced by nil. “`swift zipWithPadding([1, 2, 3], [1, 2])

    (1?, 1?), (2?, 2?), (3?, nil) ”`

    Declaration

    Swift

    public func zipWithPadding<S0: SequenceType, S1: SequenceType>(s0: S0, _ s1: S1)
      -> NilPaddedZip<S0, S1>
  • A sequence of pairs built out of two underlying sequences, where the elements of the ith pair are the ith elements of each underlying sequence. If one sequence is shorter than the other, pairs will continue to be returned after it is exhausted, but with its elements replaced by its respective pad. - Parameter pad0: the element to pad s0 with after it is exhausted - Parameter pad1: the element to pad s1 with after it is exhausted “`swift zipWithPadding([1, 2, 3], [1, 2], pad0: 100, pad1: 900)

    (1, 1), (2, 2), (3, 900) ”`

    Declaration

    Swift

    public func zipWithPadding<
      S0: SequenceType, S1: SequenceType
      >(s0: S0, _ s1: S1, pad0: S0.Generator.Element, pad1: S1.Generator.Element)
      -> PaddedZip<S0, S1>

    Parameters

    pad0

    the element to pad s0 with after it is exhausted

    pad1

    the element to pad s1 with after it is exhausted