On 9/27/05, O Plameras <[EMAIL PROTECTED]> wrote:
> I can RTFM but if I can see the  equivalent of this code, it'd be helpful.
> I wish to have a quick idea of the language.
>
> #include <stdio.h>
>
> int integer_array[] = {1,-2,3,-4,5,-6,-7,8,-9,32727000};
> int *ptr;
>
> int main(void)
> {
>     int i;
>     ptr = &integer_array[0];
>     printf("\n\n");
>     for (i = 0; i < 10; i++)
>     {
>       printf("integer_array[%d] = %d   ",i,integer_array[i]);
>       printf("ptr + %d = %d\n",i, *(ptr + i));
>     }
>     return 0;
> }

In Smalltalk:

integerArray := #(1 -2 3 -4 5 -6 -7 8 -9 32727000 9876543210).
Transcript cr.
1 to: integerArray size do: [:index|
        Transcript
                show: 'integerArray[', index printString, '] = ';
                show: (integerArray at: index) printString;
                cr].
^0

Notes:
o The index of the first position in an Array is 1
o Objects have a memory address, but only the VM knows what it is
o I popped in a larger number at the end of the Array :-)

Here is the result of evaluating the above:

integerArray[1] = 1
integerArray[2] = -2
integerArray[3] = 3
integerArray[4] = -4
integerArray[5] = 5
integerArray[6] = -6
integerArray[7] = -7
integerArray[8] = 8
integerArray[9] = -9
integerArray[10] = 32727000
integerArray[11] = 9876543210

All the best,
    Bruce
--
Make the most of your skills - with OpenSkills
http://www.openskills.org/
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to