I wrote: > Which of the two are easier to compare? Did you spot the change in the > second pseudocode? How about the 2 errors?
Raul responded: > I only see one error (the first line). I also missed a semicolon in the loop body. Hard to spot (part of the point). > You were thinking of _2 +/\ array. For 2 +/\ array you would want Yep, sorry. I guess it's possible to make a mistake in 4 characters after all :) (although this was more of a "thinko" than a "typo"). > 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 . Fencepost errors are the first, and perhaps most gratifying, class of problems one leaves behind when switching to J. > Though, properly speaking, you use "double" instead of "int" > when casting J into C. Another thing I don't have to worry about now that I use J. In fact, the story is better than that. J lets me stay with nice, parsimonious ints so long as my numbers are small enough, but automatically "upgrades" me when I need it (i.e. avoids casting to float as long as possible, rather than forcing me to make that decision up front). One thing J doesn't (yet) do is automatically downgrade me to the more parsimonious type, should my numbers ever fit back into integers. -Dan ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm