Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Pascal, contrary to what the article states, allows any subrange of integer as an array index. For example,

    kernel: array[-3..3,-3..3] of real;
is a 7x7 array. It has negative indices, e.g.

   x := kernel[-3,-3];
See https://www.tutorialspoint.com/pascal/pascal_arrays.htm

Sometimes you want negative indices, e.g. when performing a convolution on an image with a kernel.



To complement, dynamic arrays ("array of ...") are always 0-based in Delphi and Free Pascal. This was apparently introduced in Delphi 4 (1998).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: