Add more metrics

This commit is contained in:
Christoph Hagen
2023-02-01 16:44:07 +01:00
parent 0a5139fd39
commit d30222911d
5 changed files with 141 additions and 29 deletions

View File

@@ -0,0 +1,12 @@
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) }
}
}