1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 11:02:26 +03:00

SES does not take an equality test.

This commit is contained in:
Rob Rix 2015-10-14 12:14:15 -04:00
parent da11e0983a
commit e33f733d83
3 changed files with 3 additions and 3 deletions

View File

@ -82,7 +82,7 @@ public enum Algorithm<A, B> {
return f(Dictionary(elements: deleted + inserted + patched)).evaluate(equals, recur: recur)
case let .Roll(.ByIndex(a, b, f)):
return f(SES(a, b, equals: equals, recur: recur)).evaluate(equals, recur: recur)
return f(SES(a, b, recur: recur)).evaluate(equals, recur: recur)
}
}
}

View File

@ -1,7 +1,7 @@
/// Computes the SES (shortest edit script), i.e. the shortest sequence of diffs (`Free<A, Patch<A>>`) for two arrays of terms (`Fix<A>`) which would suffice to transform `a` into `b`.
///
/// This is computed w.r.t. an `equals` function, which computes the equality of leaf nodes within terms, and a `recur` function, which produces diffs representing matched-up terms.
public func SES<A>(a: [Fix<A>], _ b: [Fix<A>], equals: (A, A) -> Bool, recur: (Fix<A>, Fix<A>) -> Free<A, Patch<A>>) -> [Free<A, Patch<A>>] {
public func SES<A>(a: [Fix<A>], _ b: [Fix<A>], recur: (Fix<A>, Fix<A>) -> Free<A, Patch<A>>) -> [Free<A, Patch<A>>] {
typealias Term = Fix<A>
typealias Diff = Free<A, Patch<A>>

View File

@ -57,7 +57,7 @@ private let c = Term.Leaf(.Literal("c", []))
private let d = Term.Leaf(.Literal("d", []))
private func SES(a: [Term], _ b: [Term]) -> [Diff] {
return SES(a, b, equals: ==, recur: { Diff.Pure(Patch.Replace($0, $1)) })
return SES(a, b, recur: { Diff.Pure(Patch.Replace($0, $1)) })
}
private func == (a: [Diff], b: [Diff]) -> Bool {