could I put it into simple form: I'd like to write a verb that reads and process "each" row of a table (50 x 8) with the condition that this verb calls for two other verbs (read and write) which they need a specific path. The problem is that how can I read this table row by row and number the path's "filenames" based on the row_number that is processing?
process=: : 0 input=: read '/home/user/input/filename', row_number ,'.pgm' **some calculations** output=: write '/home/user/output/filename', row_number ,'.pgm' ) Ric Sherlock wrote: > > I'm struggling to understand exactly what you are trying to achieve > but am assuming it just involves processing a set of files. If so then > something like this might work. > > Create a 2 column table of outfilenames ,. infilenames. It doesn't > really matter how you do this but for clarity here's an example: > outpath=: 'path/out/' > inpath=: 'path/in/' > outfiles=: ((outpath,'outfile') , ,&'.txt') each 8!:0 ] i.3 > infiles=: ((inpath,'infile') , ,&'.png') each 8!:0 ] i.3 > outfiles,.infiles > ┌─────────────────────┬───────────────────┐ > │path/out/outfile0.txt│path/in/infile0.png│ > ├─────────────────────┼───────────────────┤ > │path/out/outfile1.txt│path/in/infile1.png│ > ├─────────────────────┼───────────────────┤ > │path/out/outfile2.txt│path/in/infile2.png│ > └─────────────────────┴───────────────────┘ > > Then you want to process each row of this table. The verb processData > is a placeholder for whatever processing you need to do to take the > contents of the infile and produce the contents for the outfile. > > (fwrite~ processData@fread)/"1 outfiles,.infiles > > This is essentially doing the equivalent of the following for each > pair of out and in files: > > 'out/path/outfile1.txt' (fwrite~ processData@fread) > 'in/path/infile1.png' > > HTH > > -- View this message in context: http://old.nabble.com/path-variable-in-loop-tp34413608s24193p34415893.html Sent from the J Programming mailing list archive at Nabble.com. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm