--import Test.QuickCheck --import Control.Monad --import Graph data Filesystem = Folder [Filesystem] | File deriving Show numFiles1 :: Filesystem -> Int numFiles1 File = 1 numFiles1 (Folder xs) = sum $ map numFiles1 xs numFiles2 :: Filesystem -> Int numFiles2 f = let (folders, files) = count f in files where count File = (0, 1) count (Folder f) = foldr (\(x,y) (xx,yy) -> (x+xx,y+yy)) (1,0) $ map count f