prefix

func prefix<S : Sliceable>(_: S, maxLength: Int)

Return a slice, up to maxLength in length, containing the initial elements of s.

If maxLength exceeds count(s), the result contains all the elements of s.

Complexity: O(1)+K when S.Index conforms to RandomAccessIndexType and O(N)+K otherwise, where K is the cost of slicing s.

Declaration

func prefix<S : Sliceable>(s: S, maxLength: Int) -> S.SubSlice