Here are a couple of ways to do what you want.  Each of these expects
a triplet (input dir; output dir; table) and an arbitrary verb to
apply.

workOnDirs=: 1 : 0
   'inpd outpd table'=. y
   table u inpd;outpd
NB.EG foo workOnDirs &.> ('\in1';'\in2');&.>('\out1';'\out2');&.>tables
)

So, the input data for this would be something like this:

   ('\in1';'\in2');&.>('\out1';'\out2');&.>(<2 2)$&.>1 0;1 2 3
+----------------+----------------+
|+----+-----+---+|+----+-----+---+|
||\in1|\out1|1 0|||\in2|\out2|1 2||
||    |     |1 0|||    |     |3 1||
|+----+-----+---+|+----+-----+---+|
+----------------+----------------+

loopyWay=: 1 : 0
   'inpd outpd table'=. y
   for_ix. i.#inpd do. table foo (ix{inpd);ix{outpd end.
NB.EG foo loopyWay ('\in1';'\in2');&.>('\out1';'\out2');&.>tables
)

The input data for this would be like this:

   ('\in1';'\in2');('\out1';'\out2');(<2 2)$&.>1 0;1 2 3
+-----------+-------------+---+---+
|+----+----+|+-----+-----+|1 0|1 2|
||\in1|\in2|||\out1|\out2||1 0|3 1|
|+----+----+|+-----+-----+|   |   |
+-----------+-------------+---+---+

The first of these is more J-like as it doesn't loop explicitly.
Also, the second one doesn't show the relation between the three lists
whereas the first one groups them more naturally. These examples
assume "foo" takes a left argument of the table you want to use and a
right argument of the input;output directories.

On Mon, Sep 10, 2012 at 1:29 PM, pascha <amirpasha...@gmail.com> wrote:
>
> I am quite unfamiliar with the concept of loop in J.
> what I meant about loop was the traditional "for loop" as in other
> languages, I even don't know if such a thing exists
>
> I'd like to apply two path variables (one for reading and one for writing)
> and one other table (these 3 have the array size) in such a way that I can
> extract the elements one by one and do some computation till all the arrays
> taken care of.
> in other words I have 3 inputs for the verb (input path, output path, a
> table).
> could you give some hints how can I create such a verb (or loop)?
>
>
>
> Raul Miller-4 wrote:
>>
>> Here are your 50 paths:
>>
>> paths=: ('/home/user/file', ":, '.pgm'&[)&.> 1+i.50
>>
>> If you have a verb which reads one file and processes it, and returns
>> that result, you might use either:
>>
>>    averb each paths
>>
>> or
>>
>>    averb"0 paths
>>
>> The first version gives your verb an unboxed file name, the second
>> version gives your verb a boxed file name.
>>
>> I do not know why you used the word "loop".
>>
>> I hope this helps.
>>
>> --
>> Raul
>>
>> On Mon, Sep 10, 2012 at 11:18 AM, pascha <amirpasha...@gmail.com> wrote:
>>>
>>> I want to include path variable for a verb which reads several files in a
>>> loop
>>> as an example:
>>>
>>> path = '/home/user/file'
>>> x=: read path,i,'.pgm'
>>>
>>> in which "read" is the verb, "i" starts from 1 to 50  and '.pgm' is the
>>> file
>>> extension.
>>> so in each iteration "i" would replace with number 1-50.
>>>
>>> is this possible in J?
>>> --
>>> View this message in context:
>>> http://old.nabble.com/path-variable-in-loop-tp34413608s24193p34413608.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-tp34413608s24193p34414328.html
> Sent from the J Programming mailing list archive at Nabble.com.
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to