1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

at does not return in Myers.

This commit is contained in:
Rob Rix 2017-03-09 13:53:49 -05:00
parent a41a4aa9b0
commit 9ab575b264

View File

@ -65,15 +65,13 @@ findDPath direction d k = M (FindDPath direction d k) `Then` return
data MyersState = MyersState { forward :: !(Vector.Vector Int), backward :: !(Vector.Vector Int), offset :: Diagonal }
getK :: Direction -> Diagonal -> Myers Endpoint
getK direction diagonal = do
state <- get
let v = (case direction of { Forward -> forward ; Reverse -> backward }) state
v `at` diagonal
getK direction (Diagonal diagonal) = do
MyersState forward backward (Diagonal offset) <- get
let v = case direction of { Forward -> forward ; Reverse -> backward }
return $! v `at` Diagonal (offset + diagonal)
at :: Vector.Vector Int -> Diagonal -> Myers Endpoint
at v (Diagonal k) = do
Diagonal o <- gets offset
return (Endpoint (v Vector.! o + k) 0)
at :: Vector.Vector Int -> Diagonal -> Endpoint
at v (Diagonal k) = Endpoint (v Vector.! k) 0
overlaps :: Endpoint -> Endpoint -> Bool
overlaps (Endpoint x y) (Endpoint u v) = x - y == u - v && x <= u