1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 12:23:08 +03:00

Document SES.

This commit is contained in:
Rob Rix 2015-10-06 13:08:17 -04:00
parent 90b404b3ee
commit d2b3f16cfc

View File

@ -212,6 +212,9 @@ extension FreeAlgorithm where A: Equatable, B: FreeConvertible, B.RollType == A,
}
/// 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>>] {
typealias Term = Fix<A>
typealias Diff = Free<A, Patch<A>>