This file contains hidden or 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
func qckSort<T: Comparable>(v: T[]) -> T[] { | |
switch v { | |
case []: | |
return [] | |
default: | |
let head = v[0] | |
var tail = v.copy() | |
tail.removeAtIndex(0) | |
return qckSort(tail.filter({$0 <= head})) + [head] + qckSort(tail.filter({$0 > head})) | |
} |
This file contains hidden or 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
-(NSString *) transliterate:(NSString *)string { | |
NSMutableString *str = [string mutableCopy]; | |
CFMutableStringRef nameRef = (__bridge CFMutableStringRef)str; | |
CFStringTransform(nameRef, NULL, CFSTR("Any-Latin; Latin-ASCII"), false); | |
CFStringTransform(nameRef, NULL, kCFStringTransformStripDiacritics, false); | |
return [str copy]; | |
} |
This file contains hidden or 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
extension String { | |
var isHomogeneous: Bool { | |
return Set(characters).count < 2 | |
} | |
} |
This file contains hidden or 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
extension Array { | |
var decompose: (head: Element, tail: [Element])? { | |
return (count > 0) ? (self[0],tail) : nil | |
} | |
var tail: [Element] { | |
return Array(self[1..<count]) | |
} | |
func splitAt(n: Int) -> ([Element], [Element]) { |