1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 11:02:26 +03:00

Restore the compare-parametric min function.

This commit is contained in:
Rob Rix 2015-10-07 13:09:22 -04:00
parent 10ddaab0ed
commit 47dec5546d

View File

@ -31,6 +31,10 @@ public func SES<A>(a: [Fix<A>], _ b: [Fix<A>], equals: (A, A) -> Bool, recur: (F
return stream.value.first?.1 ?? 0
}
func min<A>(a: A, _ rest: A..., _ isLessThan: (A, A) -> Bool) -> A {
return rest.reduce(a, combine: { isLessThan($0, $1) ? $0 : $1 })
}
// A matrix whose values are streams representing paths through the edit graph, carrying both the diff & the cost of the remainder of the path.
var matrix: Matrix<Stream<(Diff, Int)>>!
matrix = Matrix(width: a.count + 1, height: b.count + 1) { i, j in