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 checkIteratorState<T: Sequence, T.Element: Equatable>(sequence: T) { | |
var iterator1 = sequence.makeIterator() | |
var iterator2 = sequence.makeIterator() | |
// test equality | |
} | |
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 Equatable where Self: Sequence { | |
public static func == (lhs: Sequence<Element>, rhs: Sequence<Element>) -> Bool { | |
return elementsEqual(lhs, rhs) | |
} | |
} |
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
struct ReductionsSequence<Base: Sequence, T>: Sequence, IteratorProtocol { | |
typealias Element = T | |
private var iterator: AnyIterator<Base.Element> | |
private var current: T | |
private let reducer: (T, Base.Element) -> T | |
init(sequence: Base, initialValue: T, reducer: @escaping (T, Base.Element) -> T) { | |
iterator = AnyIterator(sequence.makeIterator()) | |
self.reducer = reducer |
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 { | |
func sortedWith<T: Comparable, U: Comparable>(_ comparableTransform: (Array.Element) -> (T, U)) -> [Array.Element] { | |
return sorted(by: { (a, b) -> Bool in | |
let tupleA = comparableTransform(a) | |
let tupleB = comparableTransform(b) | |
return tupleA.0 == tupleB.0 && tupleA.1 == tupleB.1 | |
}) | |
} | |
} |
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 { | |
func sortedWith<T: Comparable>(_ comparableTransform: (Array.Element) -> T) -> [Array.Element] { | |
return sorted(by: { (a, b) -> Bool in | |
return comparableTransform(a) > comparableTransform(b) | |
}) | |
} | |
} | |
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 where Element: Hashable { | |
func uniqueElements() -> [Element] { | |
return uniqueElements(by: { $0 }) | |
} | |
func uniqueElements<T: Hashable>(by uniqueValue: (Element) -> T) -> [Element] { | |
var uniqueElements: [Array.Element] = [] | |
var set: Set<T> = Set() | |
for element in self { | |
let value = uniqueValue(element) |
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 { | |
func sortedWith<T: Comparable>(_ comparableTransform: (Array.Element) -> T) -> [Array.Element] { | |
return sorted(by: { (a, b) -> Bool in | |
return comparableTransform(a) > comparableTransform(b) | |
}) | |
} | |
} | |
let carts: [Card] = [] |
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
#!/usr/bin/ruby | |
raise "Usage: ./framework.rb <path to pbxproj file> <name of target>" unless ARGV.size == 2 | |
proj_file, name = ARGV | |
str = IO.read(proj_file).gsub("com.apple.product-type.application", "com.apple.product-type.framework").gsub("#{name}.app", "#{name}.framework") | |
IO.write(proj_file, str) |
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 didTouchDown() { | |
self.vc = DestViewController() | |
} | |
// about 75ms elapses here... | |
func didTouchUp() { | |
presentVC(self.vc) | |
} |
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 didTouchUp() { | |
let vc = DestViewController() | |
presentVC(vc) | |
} |