Hi Pascha, If you haven't looked at Henry Rich's 'J for C Programmers', specifically Chapter 5 http://www.jsoftware.com/help/jforc/declarations.htm#_Toc191734319 and Chapter 6 http://www.jsoftware.com/help/jforc/loopless_code_i_verbs_have_r.htm#_Toc191734331 I think that is an excellent starting point for understanding how verb ranks can replace the idea of program loops.
Cheers, bob On 2012-09-11, at 9:04 AM, pascha wrote: > > Right, the main problem for me is I've troubles to understand iteration of > verbs over array dimension > any suggestion for tutorial? > > > aks_sba wrote: >> >> Pascha, >> >> The people who have been responding are trying to help you understand the >> "j way" to get your problem addressed. In other words, they have been >> showing you how to solve the problem using "loop less" J sentences. >> >> In order for you to really understand these helpful suggestions, you have >> to understand how iteration of verbs across an array dimension is implicit >> in the language. >> >> However, j is certainly capable of iterating manually over data; just use >> a control structure as described in the lhttp below: >> >> http://www.jsoftware.com/docs/help701/jforc/control_structures.htm#_Toc191734474 >> >> Sent from my iPhone >> >> On Sep 10, 2012, at 4:41 PM, pascha <amirpasha...@gmail.com> wrote: >> >>> >>> 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 >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > -- > View this message in context: > http://old.nabble.com/path-variable-in-loop-tp34413608s24193p34419238.html > Sent from the J Programming mailing list archive at Nabble.com. > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm