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
rn: rn.c | |
test: rn | |
./rn I IV V VI IX X XI XIV XIX XCIX CI MCMLXVII MD MDC MCD MM | |
.PHONY: test |
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
// Implementation of If, ElseIf, and Else in Swift. | |
// | |
// Supports uses such as these: | |
// | |
// If (condition) { doAction() } | |
// | |
// If (condition) { doAction() } | |
// .Else { doOtherAction() } | |
// | |
// If (condition) { doAction() } |
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
import Foundation | |
extension Array { | |
/// Returns a new `Array` made by appending a given element to the `Array`. | |
func appending(_ newElement: Element) -> Array { | |
var a = Array(self) | |
a.append(newElement) | |
return a | |
} | |
} |
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
extension Array { | |
/// Returns a new `Array` made by appending a given element to the `Array`. | |
func appending(_ newElement: Element) -> Array { | |
var a = Array(self) | |
a.append(newElement) | |
return a | |
} | |
} |
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
extension String { | |
/// Returns substring starting from given numeric index to the end of the string. | |
func substring(fromNumericIndex numericIndex: Int) -> String { | |
return self.substring(from: self.index(self.startIndex, offsetBy: numericIndex)) | |
} | |
} |
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
/// Returns a sequence of Fibonacci numbers. | |
/// | |
/// The sequence is [1, 1, 2, 3, 5, 8, 13, ...]. | |
/// | |
/// The sequence is not infinite; it terminates when | |
/// the next value would be greater than | |
/// `Int.max`. | |
/// | |
/// - returns: A sequence of Fibonacci numbers. | |
public func fibonacciSequence() -> AnySequence<Int> { |
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
import Foundation | |
extension FileHandle { | |
/// Return an iterator over the bytes in the file. | |
/// | |
/// - returns: An iterator for UInt8 elements. | |
public func bytes() -> FileHandleByteIterator { | |
return FileHandleByteIterator(fileHandle: self) | |
} |
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
import CoreGraphics | |
extension CGPath { | |
/// Call the given closure on each element of the path. | |
func forEach(_ body: @escaping (CGPathElement) -> Void) { | |
var info = body | |
self.apply(info: &info) { (infoPtr, elementPtr) in | |
let opaquePtr = OpaquePointer(infoPtr!) | |
let body = UnsafeMutablePointer<(CGPathElement) -> Void>(opaquePtr).pointee | |
body(elementPtr.pointee) |
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
import CoreGraphics | |
extension CGPoint { | |
/// Calculate Y-axis distance between a point and a line segment. | |
/// | |
/// - parameter endpointA: One endpoint of the line segment. | |
/// - parameter endpointB: The other endpoint of the line segment. | |
/// | |
/// - returns: Distance, or `nil` if this point's x-coordinate is not between those of the endpoints. |
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
---------- | |
2016-10-25 | |
---------- | |
06:15 AM - F.B.I. Story, The (1959) | |
Description: A dedicated FBI agent thinks back on the agency's battles against the Klan, organized crime and Communist spies. | |
Genres: Drama, Crime, Adaptation | |
Directed by: Mervyn LeRoy, David Silver, Gil Kissel, Jack Boland | |
Written by: Richard L. Breen, John Twist |