Add more metrics
This commit is contained in:
12
Sources/App/Extensions/Sequence+Extensions.swift
Normal file
12
Sources/App/Extensions/Sequence+Extensions.swift
Normal 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) }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user