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
// MARK: Transform an array of items | |
extension Array where Element: Sendable { | |
/// Execute a throwing task for each element of the array. | |
/// | |
/// - All tasks are executed concurrently, | |
/// - If the transformer is `nonisolated` all tasks are executed in parallel . | |
/// - The resulting array maintains the same order as the original array. | |
/// - If any task throws any error, all tasks are allowed to complete. The resulting error includes a array of | |
/// results where successful elements can be used and failed elements can be handled. | |
/// |
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
//: 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 { |
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
import Cocoa | |
// a = 97 | |
// z = 122 | |
let value = UInt8(ascii: "z") | |
extension Character { | |
var testValues: UInt8? { |
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
import Cocoa | |
// a = 97 | |
// z = 122 | |
let value = UInt8(ascii: "z") | |
extension Character { | |
var testValues: UInt8? { |
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
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) { |