I think I badly explained myself, or maybe i completely misunderstood the code:

>      next=.5&(0 3 + *)

the verb next simply applies the "multiply by five and add 3" to is right 
argument a number of times given by is left argument, right?

>      (i. 20) next 1 0

this instruction, first applies 0 times "next" to 1 0, then applies once "next" 
to 1 0, then applies twice "next" to 1 0, ... , then applies 20 times "next" to 
1 0, right?

this mean that S(0) has been calculated 20 times, S(1) has been calculated 19 
times, S(n) has been calculated 20-n times since every time the function next 
restarts from
the first term (which is 1 0), right?

What i mean is that with something like the following pseudo-code S(n) is 
calculated once avoiding a huge waste of time and memory:

S(1)=1 0
for i=2 to 20 do
   S(i)=.3+5*S(i-1)
end

My question then was if the code:

>      next=.0 3+*&5
>      20 next@]^:(i.@[) 1 0

has the same problem or not and, in case of a positive answer, how can i 
translate my pseudo-code in J avoiding an explicit loop.

It may be that I completely misunderstood your code and the problem that is 
worring me doesn't exist at all but I'm really a beginner in J...

Alessandro




                                          
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to