1
0
forked from GitHub/gf-core
This commit is contained in:
aarne
2005-10-11 15:03:44 +00:00
parent 0d33fd98e0
commit cbcac43e31
5 changed files with 112 additions and 0 deletions

View File

@@ -118,3 +118,20 @@ lin2fun s = case words s of
_ -> s
where
cat fun = reverse (takeWhile (/='_') (reverse fun))
-- filter from a given file those lines whose first word is in a sought-set
allThose :: [String] -> [String] -> [String]
allThose soughts givens = concatMap seek soughts where
seek w = let s = [line | line <- givens, w':_ <- [words line], w == w']
in if null s then ["-- " ++ w] else s
-- do this with files
-- example: getAllThose "abstract/Mtmp" "english/BasicEng.gf"
getAllThose :: FilePath -> FilePath -> IO ()
getAllThose sought given = do
s <- readFile sought
gi <- readFile given
let so = [w | l <- lines s, w:_ <- [words l]]
mapM_ putStrLn $ allThose so $ lines gi