tools/unitCycles.hs
changeset 4384 615a3e7bd850
parent 4382 935de6cd5ea3
--- a/tools/unitCycles.hs	Thu Nov 18 16:58:08 2010 -0500
+++ b/tools/unitCycles.hs	Sat Nov 20 22:05:01 2010 +0300
@@ -25,10 +25,10 @@
 myf d = unlines . map (findCycle . fst) $ d
     where
     findCycle :: String -> String
-    findCycle searched = intercalate ", " $ fc searched [searched]
+    findCycle searched = searched ++ ": " ++ (intercalate ", " $ fc searched [])
         where
         fc :: String -> [String] -> [String]
-        fc curSearch visited = let uses = curSearch `lookup` d in if isNothing uses then [] else concatMap t $ fromJust uses
+        fc curSearch visited = let uses = curSearch `lookup` d; res = dropWhile null . map t $ fromJust uses in if isNothing uses || null res then [] else head res
             where
             t u =
                 if u == searched then