Skip to content

Instantly share code, notes, and snippets.

@tmu
Created August 26, 2014 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmu/3db6d6bcafd6b6fb8b68 to your computer and use it in GitHub Desktop.
Save tmu/3db6d6bcafd6b6fb8b68 to your computer and use it in GitHub Desktop.
Code that crashes Swift compiler frontend
// Run with
// xcrun swift -O 028-reduce-over-extensible-collection.swift
func deleteDuplicates<S:ExtensibleCollectionType where S.Generator.Element: Comparable>(seq:S)-> S {
let s = reduce(seq, S()){
ac, x in contains(ac,x) ? ac : ac + [x]
}
return s
}
var str = "Hello, playground"
str = deleteDuplicates(str)
println(str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment