Well... J does have control structures, though only in explicit verbs
(and explicit adverbs and explicit conjunctions):
http://www.jsoftware.com/help/dictionary/ctrl.htm

That said, when you say "one by one" it's usually a good idea to say
why you want to do things that way.  "One by one" processing in J
tends to be slow, so mostly it's a good fit for things that already
take a while (then you can ignore the extra millisecond? needed to
handle each item, one by one).  File processing probably fits,
though...

Anyways, the way you are currently describing things, I think I would
want to identify files by index number (1..50), and then I would have
a verb that gives me the read file name for an index number and
another verb that gives me the write file name for an index number.
Then I could write a routine to process a file index and it could use
these verbs to determine which file pair to work on.  Or, if it was
the only verb to deal with these files, maybe I would just hard-code
the algorithm into the verb itself.

But I might be failing to understand something important about your
computations?

-- 
Raul

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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to