Schafkopf-Server/Sources/App/Extensions/Sequence+Extensions.swift

13 lines
266 B
Swift
Raw Permalink Normal View History

2023-02-01 16:44:07 +01:00
import Foundation
extension Sequence {
func count(where isIncluded: (Element) -> Bool) -> Int {
reduce(0) { isIncluded($1) ? $0 + 1 : $0 }
}
func sum(converting: (Element) -> Int) -> Int {
reduce(0) { $0 + converting($1) }
}
}