- To: slug@xxxxxxxxxxx
- Subject: Re: [SLUG] Your top-ten linux desktop apps
- From: Bruce Badger <bwbadger@xxxxxxxxx>
- Date: Tue, 27 Sep 2005 14:54:37 +1000
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=syyIBSoql060W/2PZEFrYVMpUHrm9HAEROhwHia85HYXtgFigk2m9ZNJvF+WUvStiNYd2qL2YjuUj6hrBdeSC6rXm2sEt9DhopHldpz6SYfVWq91PdfdURHGiMu6WQGRJxwFafQqB3bbpsYi6k38A+FBbTC3uCP7nGZfE28CszA=
- Reply-to: Bruce Badger <bwbadger@xxxxxxxxx>
On 9/27/05, O Plameras <oscarp@xxxxxxxxxxx> 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/