Skip to content
This repository was archived by the owner on Jul 8, 2018. It is now read-only.

Commit 0fa7256

Browse files
committed
fdupes.hs: write simpler version which actually works
Ignore-this: 982d22529583d97d9babe1cd890b46e6 darcs-hash:20100220152459-f7719-220194597b1a9ad2fecb19b9c536ee285bf1c6fb
1 parent b57e2a5 commit 0fa7256

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

fdupe.hs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import Data.List.Split (splitWhen)
2-
import Control.Monad (liftM)
1+
import Data.List.Split (splitOn)
32

43
main :: IO ()
5-
main = do arg <- liftM (concat . map (fun . lines) . breakBlankLines) $ getContents
6-
mapM_ putStrLn arg
4+
main = interact (unlines . map (linkify . lines) . splitOn "\n\n")
75

8-
breakBlankLines :: String -> [String]
9-
breakBlankLines = map (\x -> if head x == '\n' then tail x else x) . filter (not . (==) "") . map concat . splitWhen (=="") . splitWhen (=='\n')
10-
11-
fun :: [String] -> [String]
12-
fun strs = map (\x -> "ln -sf " ++ "\'" ++ (head strs) ++ "\' " ++ "\'" ++ x ++ "\'") $ tail strs
6+
linkify :: [String] -> String
7+
linkify (x:xs) = unlines $ map (\y -> "ln -sf " ++ show x ++ " " ++ show y) xs

0 commit comments

Comments
 (0)