Created
August 26, 2014 18:24
-
-
Save tmu/3db6d6bcafd6b6fb8b68 to your computer and use it in GitHub Desktop.
Code that crashes Swift compiler frontend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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