From 47dec5546d7f7343b820c679940ea3ca47cc0ed5 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 7 Oct 2015 13:09:22 -0400 Subject: [PATCH] Restore the compare-parametric `min` function. --- prototype/Doubt/SES.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prototype/Doubt/SES.swift b/prototype/Doubt/SES.swift index c4566c4e7..2c00a7805 100644 --- a/prototype/Doubt/SES.swift +++ b/prototype/Doubt/SES.swift @@ -31,6 +31,10 @@ public func SES(a: [Fix], _ b: [Fix], equals: (A, A) -> Bool, recur: (F return stream.value.first?.1 ?? 0 } + func min(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>! matrix = Matrix(width: a.count + 1, height: b.count + 1) { i, j in