mirror of
https://github.com/github/semantic.git
synced 2024-11-25 11:04:00 +03:00
Generalize SES to arbitrary arrays.
This commit is contained in:
parent
34258b98b8
commit
0acdd16db3
@ -1,8 +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>], recur: (Fix<A>, Fix<A>) -> Free<A, Patch<Fix<A>>>) -> [Free<A, Patch<Fix<A>>>] {
|
||||
typealias Term = Fix<A>
|
||||
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)) } }
|
||||
|
Loading…
Reference in New Issue
Block a user