Skip to content

Instantly share code, notes, and snippets.

@alekseypotapov-dev
Created September 20, 2016 12:39
Show Gist options
  • Select an option

  • Save alekseypotapov-dev/ff836fef76de2d0ed9f0d833b1cca586 to your computer and use it in GitHub Desktop.

Select an option

Save alekseypotapov-dev/ff836fef76de2d0ed9f0d833b1cca586 to your computer and use it in GitHub Desktop.
Unique Sequence
func uniq<S: SequenceType, E: Hashable where E==S.Generator.Element>(source: S) -> [E] {
var seen: [E:Bool] = [:]
return source.filter { seen.updateValue(true, forKey: $0) == nil }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment