« September 2006 | Main | September 2007 »

January 2007 Archives

January 16, 2007

What the Haskell!?

I know I said my next directory recurser would be in Ruby, but Haskell has drawn my attention in a big way. Here's what I came up with...

module Main     where

import IO
import System
import Directory

main = do
  [recDir] <- getArgs
  printDirectory recDir

printDirectory path = do
  putStrLn path
  contents <- getDirectoryContents path
  mapM_ (\f -> do
      let newPath = (path ++ "/" ++ f)
      isaDir <- doesDirectoryExist newPath
      if isaDir
           then printDirectory newPath
           else putStrLn newPath
      ) (drop 2 contents)

Haskell seems like a pretty sweet language that I can learn a lot from. The pattern matching is very sweet and I'm looking forward to having a good understanding of Monads.

About January 2007

This page contains all entries posted to Avidity Software in January 2007. They are listed from oldest to newest.

September 2006 is the previous archive.

September 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.