1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 08:54:14 +03:00

Parameterized sum over Patch.

This commit is contained in:
Rob Rix 2015-10-15 15:23:36 -04:00
parent 856abbe611
commit 45d2697c46

View File

@ -53,6 +53,16 @@ extension Patch {
}
// MARK: - Cost calculations
extension Patch {
/// Returns a function which computes the size of a `patch` as the sum of the sizes of its terms, as computed by `size`.
public static func sum(size: A -> Int)(_ patch: Patch) -> Int {
return (patch.state.before.map(size) ?? 0) + (patch.state.after.map(size) ?? 0)
}
}
// MARK: - JSON
extension Patch {