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) } } }