Walk a directory/Recursively: Difference between revisions

m
→‎{{header|Haskell}}: Minor tidying, applied hlint, hindent.
(→‎{{header|Python}}: Add Python 3 method via pathlib.Path.rglob())
m (→‎{{header|Haskell}}: Minor tidying, applied hlint, hindent.)
Line 1,017:
import System.IO
 
dir_walkdirWalk :: FilePath -> (FilePath -> IO ()) -> FilePath -> IO ()
dir_walk topdirWalk filefunc top = do
isDirectory <- doesDirectoryExist top
if isDirectory
then do
files <- listDirectory top
do
mapM_ (dirWalk filesfilefunc <- listDirectory. (top </>)) files
else filefunc top
mapM_ (\file -> dir_walk (top </> file) filefunc) files
else
filefunc top
 
main :: IO ()
main = do
hSetEncoding stdout utf8
hSetEncoding stdin utf8
let worker fname =
| do if (takeExtension fname == ".hs") = putStrLn fname
| otherwise = return then putStrLn fname()
dirWalk worker "."</lang>
else return ()
dir_walk "." worker</lang>
 
== Icon and Unicon ==
9,655

edits