@@ -183,12 +183,11 @@ canDiag eq as bs lena lenb = \ i j ->
183183-- * An 'F' (delete) move: 'poi' incremented by 1.
184184-- * An 'S' (insert) move: 'poj' incremented by 1.
185185--
186- -- 'addsnake' is applied to each candidate immediately to extend it along any
187- -- available sequence of matching elements.
188- --
189186-- The resulting candidates are merged pairwise: the vertical successor of each
190187-- node is paired with the horizontal successor of the next node in the wave
191- -- front. When this function is iterated from a single-node seed (as in 'ses'),
188+ -- front. The 'furthestReaching' between them is extended along the available
189+ -- sequence of matching elements using 'addsnake'.
190+ -- When this function is iterated from a single-node seed (as in 'ses'),
192191-- each such pair always lies on the same diagonal: an 'F' edge advances to the
193192-- next higher diagonal while an 'S' edge retreats to the next lower one, so the
194193-- two members of each pair straddle the same diagonal from opposite sides.
@@ -199,16 +198,17 @@ dstep
199198 -> [DL ] -- ^ A non-empty wave front of nodes at edit distance D
200199 -> [DL ] -- ^ A non-empty wave front of nodes at edit distance D+1
201200dstep _ [] = error " dstep: Cannot perform expansion on an empty list of nodes"
202- dstep cd (dl: dls) = hStep dl : stepAndMerge dl dls
201+ dstep cd (dl: dls) = addsnake cd ( hStep dl) : stepAndMerge dl dls
203202 where
204- hStep node = addsnake cd $ node {poi = poi node + 1 , path = F : path node}
205- vStep node = addsnake cd $ node {poj = poj node + 1 , path = S : path node}
203+ hStep node = node {poi = poi node + 1 , path = F : path node}
204+ vStep node = node {poj = poj node + 1 , path = S : path node}
206205 -- Merge vertical step of previous node with horizontal step of next node,
207- -- selecting the furthest-reaching candidate for each shared k-diagonal.
206+ -- selecting the furthest-reaching candidate for each shared k-diagonal,
207+ -- and extend it along matching elements.
208208 stepAndMerge :: DL -> [DL ] -> [DL ]
209- stepAndMerge prev [] = [vStep prev]
209+ stepAndMerge prev [] = [addsnake cd $ vStep prev]
210210 stepAndMerge prev (next: rest) =
211- furthestReaching (vStep prev) (hStep next) : stepAndMerge next rest
211+ addsnake cd ( furthestReaching (vStep prev) (hStep next) ) : stepAndMerge next rest
212212
213213-- | Follow a /snake/ from the current position of a 'DL' node.
214214--
0 commit comments