From a7f4d91d56cfb3088bf685024cc907a8b2b5b31a Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 14 Oct 2015 12:25:38 -0400 Subject: [PATCH] Revert "SES does not take an equality test." This reverts commit 1db8bdf82c85a490188882b810cd9c516e4f210e. Conflicts: prototype/Doubt/SES.swift prototype/DoubtTests/SESTests.swift --- prototype/Doubt/Algorithm.swift | 2 +- prototype/Doubt/SES.swift | 2 +- prototype/DoubtTests/SESTests.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/prototype/Doubt/Algorithm.swift b/prototype/Doubt/Algorithm.swift index 56dab9f97..fa63dbd69 100644 --- a/prototype/Doubt/Algorithm.swift +++ b/prototype/Doubt/Algorithm.swift @@ -85,7 +85,7 @@ public enum Algorithm { 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) } } } diff --git a/prototype/Doubt/SES.swift b/prototype/Doubt/SES.swift index 7317d7bc2..2a98bcbdc 100644 --- a/prototype/Doubt/SES.swift +++ b/prototype/Doubt/SES.swift @@ -1,7 +1,7 @@ /// Computes the SES (shortest edit script), i.e. the shortest sequence of diffs (`Free>`) for two arrays of terms (`Fix`) 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: [Term], _ b: [Term], recur: (Term, Term) -> Free>?) -> [Free>] { +public func SES(a: [Term], _ b: [Term], equals: (Term, Term) -> Bool, recur: (Term, Term) -> Free>?) -> [Free>] { typealias Diff = Free> if a.isEmpty { return b.map { Diff.Pure(Patch.Insert($0)) } } diff --git a/prototype/DoubtTests/SESTests.swift b/prototype/DoubtTests/SESTests.swift index ae499ca95..0dff2f014 100644 --- a/prototype/DoubtTests/SESTests.swift +++ b/prototype/DoubtTests/SESTests.swift @@ -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 {