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:
parent
856abbe611
commit
45d2697c46
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user