View Problem

Process each file in a directory

DiskEdit
python 2.4
import os
results = (process(f) for f in os.listdir(".") if os.path.isfile(f))
ExpandDiskEdit
clojure
; (defn process-file [f] "process one file" body...)
(map process-file (.listFiles (File. ".")))
DiskEdit
csharp
foreach (string filename in System.IO.Directory.GetFiles(directory)) ProcessFile(filename);
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
cpp C++/CLI .NET 2.0
for each(String^ filename in IO::Directory::GetFiles(dirname)) process(filename);

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