mirror of
https://github.com/github/semantic.git
synced 2024-11-25 11:04:00 +03:00
Revert "SES does not take an equality test."
This reverts commit 1db8bdf82c85a490188882b810cd9c516e4f210e. Conflicts: prototype/Doubt/SES.swift prototype/DoubtTests/SESTests.swift
This commit is contained in:
parent
8d4a91d3a9
commit
a7f4d91d56
@ -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, recur: recur)).evaluate(equals, recur: recur)
|
||||
return f(SES(a, b, equals: equals, 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], recur: (Term, Term) -> Free<A, Patch<Term>>?) -> [Free<A, Patch<Term>>] {
|
||||
public func SES<Term, A>(a: [Term], _ b: [Term], equals: (Term, Term) -> Bool, 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, recur: const(nil))
|
||||
return SES(a, b, equals: ==, recur: const(nil))
|
||||
}
|
||||
|
||||
private func == (a: [Diff], b: [Diff]) -> Bool {
|
||||
|
Loading…
Reference in New Issue
Block a user