[Swift-devel] Q of traversing all files in one directory

Zhao Zhang zhaozhang at uchicago.edu
Mon Dec 29 13:05:04 CST 2008


Hi, All

Sorry to send out a Q in Holiday time.
My question is about Chapter 3.7 of swift tutorial, the foreach 
statement and regexp_mapper.

In the following code example, all input files are listed in the string.

string inputNames = "one.txt two.txt three.txt";  
  
messagefile inputfiles[] <fixed_array_mapper; files=inputNames>;    
  
foreach f in inputfiles {  
  countfile c <regexp_mapper;  
               source=@f,  
               match="(.*)txt",  
               transform="\\1count">;  
  c = countwords(f);  
}


How can I say that

foreach file in a directory {
   outfile = app(file)
}

In swift ?


Those file names are fasta00, fasta01, fasta02, ..., fasta100, 
fasta101,..., hundreds of them.
Thanks.

Happy New Year
zhao



More information about the Swift-devel mailing list