From 32bfdc676610db13834e8a12e980c62ea4c2d65c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 13 Oct 2015 17:50:22 -0400 Subject: [PATCH] Factor out right/down. --- prototype/Doubt/SES.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/prototype/Doubt/SES.swift b/prototype/Doubt/SES.swift index 7ec8b4e5d..572002c1e 100644 --- a/prototype/Doubt/SES.swift +++ b/prototype/Doubt/SES.swift @@ -53,17 +53,19 @@ public func SES(a: [Fix], _ b: [Fix], equals: (A, A) -> Bool, recur: (F } if let right = right, down = down, diagonal = diagonal { + let right = (right, Diff.Pure(Patch.Delete(a[i])), costOfStream(right)) + let down = (down, Diff.Pure(Patch.Insert(b[j])), costOfStream(down)) // nominate the best edge to continue along if let compareHere = recur(a[i], b[j]) { let (best, diff, _) = min( (diagonal, compareHere, costOfStream(diagonal)), - (right, Diff.Pure(Patch.Delete(a[i])), costOfStream(right)), - (down, Diff.Pure(Patch.Insert(b[j])), costOfStream(down))) { $0.2 < $1.2 } + right, + down) { $0.2 < $1.2 } return cons(diff, rest: best) } else { let (best, diff, _) = min( - (right, Diff.Pure(Patch.Delete(a[i])), costOfStream(right)), - (down, Diff.Pure(Patch.Insert(b[j])), costOfStream(down))) { $0.2 < $1.2 } + right, + down) { $0.2 < $1.2 } return cons(diff, rest: best) } }