Commits

Luke Plant committed 600b34d

Eliminate the boring result edge case.

  • Participants
  • Parent commits 47667dd

Comments (0)

Files changed (1)

File phone2word.hs

 type WordMap = [((Int,Int),[B.ByteString])]
 
 -- (We might need a better structure than a simple association list for WordMap
--- future, but in some functions the association list will be just right)
+-- in the future, but in some functions the association list will be right)
 type WordList = [((Int,Int),[B.ByteString])]
 
 findCombos :: B.ByteString -> WordTree -> [Combo]
          rightBank = (totalLength, 1)
 
      findRoutes :: WordMap -> [Combo]
-     findRoutes wordMap = findRoutes' (findWordEntries wordMap) 0 totalLength
+     findRoutes wordMap =
+         let combos = findRoutes' (findWordEntries wordMap) 0 totalLength
+         in
+           -- it's possible for boring entries to slip through in the case
+           -- where there are no words found at all
+           case combos of
+             [[seg]] | not $ hasWord seg -> []
+             _ -> combos
 
      findRoutes' :: WordList -> Int -> Int -> [Combo]
      findRoutes' words start end =