Commits

Luke Plant committed da41691

Eliminate some boring outputs

  • Participants
  • Parent commits 64c04c3

Comments (0)

Files changed (1)

File phone2word.hs

            -- If no matches, we still need the search to continue, because the
            -- result might be interesting even if it is not entirely composed of
            -- words.
-           then [digits]
+           -- However, we don't want to add this 'boring' item if there are
+           -- 'interesting' alternatives.  Since we have already calculated
+           -- subcombos, we can find out if there are interesting combos.
+           -- We check all 'tails' of digits for something interesting,
+           -- excluding the full string.
+           then if any (\w ->
+                            case Map.lookup w cache of
+                              Nothing -> False
+                              Just ms -> any interesting ms
+                            || (not $ null $ findWords w tree)
+                       ) (B.tails digits)
+                then matches
+                else [digits]
            else matches
 
     combineParts :: [Segment] -> ([Combo], Cache) -> ([Combo], Cache)
   putStrLn ""
 
   mainLoop wordTree
+
+
+-- TODO - fix 07956121485 - need to cache parts like '56121' to avoid boring outputs