We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c959ce2 commit 2a57e46Copy full SHA for 2a57e46
stdlib/public/core/Sequence.swift
@@ -583,6 +583,18 @@ extension SequenceType where Generator.Element : Equatable {
583
return split(maxSplit, allowEmptySlices: allowEmptySlices,
584
isSeparator: { $0 == separator })
585
}
586
+
587
+ /// Return an `Array` containing the elements of `self`
588
+ @warn_unused_result
589
+ public func uniq() -> [Generator.Element] {
590
+ return reduce(Array<Generator.Element>()) { (arr, element) -> [Generator.Element] in
591
+ if arr.contains({ $0 == element }) { return arr }
592
593
+ var newArr = arr
594
+ newArr.append(element)
595
+ return newArr
596
+ }
597
598
599
600
extension SequenceType {
0 commit comments