ひさしぶりにHaskellを書いた

最近疲れ気味でサボってたけど、ひさしぶりにHaskellを書いた。ただでさえ分かってないのに忘れかかってた。hugsで動きます。

import Directory

ls_r path = let contents = getDirectoryContents path
                     in do { c <- contents
                               ; print c
                               ; mapM_ (ls_r' path) (filter (notParentAndCurrent) c)
                               }
  where
    ls_r' = \x y -> let p = x ++ "/" ++ y
                          in do { b <- doesDirectoryExist p
                                     ; case b of
                                           True  -> ls_r p
                                           False -> return ()
                                     }

    notParentAndCurrent = \x -> and [ not $ parent x, not $ current x]

    parent = \x -> x == ".."

    current = \x -> x == "."