View Problem

Process each file in a directory

ExpandDiskEdit
clojure
; (defn process-file [f] "process one file" body...)
(map process-file (.listFiles (File. ".")))
ExpandDiskEdit
erlang
% File basenames only - many tasks require absolute paths to work
lists:foreach(fun (FileOrDirPath) -> Worker(FileOrDirPath) end, file:list_dir(Directory)).
ExpandDiskEdit
erlang
% Absolute paths provided - will accomodate most tasks
lists:foreach(fun (FileOrDirPath) -> Worker(FileOrDirPath) end, list_dir_path(Directory)).
ExpandDiskEdit
fsharp
let dirname = "c:\\"

let processFile filename = printfn "%s" filename
for filename in Directory.GetFiles(dirname) do processFile filename done
ExpandDiskEdit
fsharp
let dirname = "c:\\"

Directory.GetFiles(dirname) |> Array.iter (fun filename -> printfn "%s" filename)
ExpandDiskEdit
groovy
dir.eachFile{ f -> process(f) }

Submit a new solution for clojure, erlang, fsharp, or groovy
There are 11 other solutions in additional languages (cpp, csharp, fantom, haskell ...)