From 53e3928b3d4e7b7769e6bd2dc0d123b571d1cdcd Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 27 Nov 2015 09:46:51 -0500 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20close=20over=20the=20head=20of?= =?UTF-8?q?=20the=20list.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SES.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SES.hs b/src/SES.hs index 2f4bad946..5548083ec 100644 --- a/src/SES.hs +++ b/src/SES.hs @@ -15,9 +15,7 @@ ses :: Compare a annotation -> Cost a annotation -> [Term a annotation] -> [Term ses _ _ [] b = (Pure . Insert) <$> b ses _ _ a [] = (Pure . Delete) <$> a ses diffTerms cost (a : as) (b : bs) = case diffTerms a b of - Just f -> minimumBy (comparing sumCost) [ delete, insert, copy ] - where - copy = f : ses diffTerms cost as bs + Just f -> minimumBy (comparing sumCost) [ delete, insert, copy f ] Nothing -> minimumBy (comparing sumCost) [ delete, insert ] where delete = (Pure . Delete $ a) : ses diffTerms cost as (b : bs) @@ -25,3 +23,4 @@ ses diffTerms cost (a : as) (b : bs) = case diffTerms a b of deleteCost = sumCost delete insertCost = sumCost insert sumCost a = sum $ cost <$> a + copy head = head : ses diffTerms cost as bs