On Mon, Nov 23, 2009 at 4:42 PM, Dan Bron <j...@bron.us> wrote:
> I also missed a semicolon in the loop body.  Hard to spot (part of the
> point).

Oh... I would ignore that error if I were programming in C
for real -- the compiler catches and reports that kind of
problem, and fixing it is usually trivial.

>>  int[] r= int[array.size-1]
>>  for (int j= 0; j < array.size; j++)
>>    r[j]= array[j]+array[j+1]
>
> This code, like my original, would cause an exception when  j=
> -1+array.size  and it tries to access  array[j+1]  .  I guess the loop
> bound should be  j< -1+array.size  .

Yes.

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

Reply via email to