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 where Element: Hashable { | |
/// Returns most popular member of the array | |
/// | |
/// - SeeAlso: https://en.wikipedia.org/wiki/Mode_(statistics) | |
/// | |
typealias ArrayMode = (item: Element?, count: Int) | |
func mode() -> (item: Element?, count: 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 Cocoa | |
// a = 97 | |
// z = 122 | |
let value = UInt8(ascii: "z") | |
extension Character { | |
var testValues: UInt8? { |
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 Cocoa | |
// a = 97 | |
// z = 122 | |
let value = UInt8(ascii: "z") | |
extension Character { | |
var testValues: UInt8? { |
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
//: Playground - noun: a place where people can play | |
import Cocoa | |
// Generate the appropriate integer value for each character using | |
// a the ascii value from the return unicodeScalars. | |
// UInt8 (Unsigned 8 bit Integer) | |
// a | A = 1 | |
// z | Z = 26 | |
// all others will be 0 | |
extension Character { |