Counting from zero
duncanmak at gmail.com
Tue May 2 06:45:06 UTC 2006
On 5/2/06, Ralph Johnson <johnson at cs.uiuc.edu> wrote:
> I bet that in a typical month of Smalltalk programming, I don't ever
> need to know whether arrays are indexed starting from 1 or 0. That is
> a low-level implementation detail. Arrays are low-level
> implementation details. Program at a high level!
I was in a compiler class and was doing a project in Scheme. Like the style
prefered by Smalltalk, I strived to use only higher-order functions, like
map, instead of doing explicit iterations (Scheme makes that hard anyhow).
However, I ran into trouble when I had to iterate two collections together,
but each at a different offset, i..e matching a[i] to b[i + 2]. My
solution in the end was to use a named let, which is not quite the same as a
for loop in C, but if I were writing this in Smalltalk I wouldn't know how
to do it with only do:, collect:, select:, etc either.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev