On Sun, Nov 22, 2009 at 8:32 PM, Dan Bron <j...@bron.us> wrote:
>    int result = 0;
>    for (int i = 0; i < array.size; i++)
>    {
>        result *= array[i]
>    }
>
> vs
>    */  array                             NB.  Even handles integer
> overflow!
>
>
> Which of the two are easier to compare?  Did you spot the change in the
> second pseudocode?  How about the 2 errors?

I only see one error (the first line).

>   int[] result = int[math.ceiling( ((float) array.size) / 2.0)];
>   for(int i = 0; i < array.size; i+=2)
>   {
>      result[i] = array[i]+array[i+1];
>   }
>
> vs
>
>   2 +/\ array

You were thinking of _2 +/\ array.  For 2 +/\ array you would want

int[] r= int[array.size-1]
for (int j= 0; j < array.size; j++)
   r[j]= array[j]+array[j+1]


Though, properly speaking, you use "double" instead of "int"
when casting J into C.

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

Reply via email to