mirror of
https://github.com/github/semantic.git
synced 2024-11-25 11:04:00 +03:00
Revert "Revert "SES does not take an equality test.""
This reverts commit bb73f6eac2b59599607369767e9e221e7e5e0f15.
This commit is contained in:
parent
d0d96d569d
commit
517c87c303
@ -85,7 +85,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<Term, A>(a: [Term], _ b: [Term], equals: (Term, Term) -> Bool, recur: (Term, Term) -> Free<A, Patch<Term>>?) -> [Free<A, Patch<Term>>] {
|
||||
public func SES<Term, A>(a: [Term], _ b: [Term], recur: (Term, Term) -> Free<A, Patch<Term>>?) -> [Free<A, Patch<Term>>] {
|
||||
typealias Diff = Free<A, Patch<Term>>
|
||||
|
||||
if a.isEmpty { return b.map { Diff.Pure(Patch.Insert($0)) } }
|
||||
|
@ -57,7 +57,7 @@ private let c = Term.Leaf("c")
|
||||
private let d = Term.Leaf("d")
|
||||
|
||||
private func SES(a: [Term], _ b: [Term]) -> [Diff] {
|
||||
return SES(a, b, equals: ==, recur: const(nil))
|
||||
return SES(a, b, recur: const(nil))
|
||||
}
|
||||
|
||||
private func == (a: [Diff], b: [Diff]) -> Bool {
|
||||
|
Loading…
Reference in New Issue
Block a user