[THYME]Arrays
7 posts • Page 1 of 1
[THYME]Arrays
I have discovered something interesting in algodoo.
Arrays can be embedded!
Example:
row1=[[1,1,1,1],[1,0,0,1]]
row2=[[0,0,0,1],[1,1,0,1]]
screen=[row1,row2]
or
screen=[[[1,1,1,1],[1,0,0,1]],[[0,0,0,1],[1,1,0,1]]]
Results:
screen(0)=[[1,1,1,1],[1,0,0,1]]
screen(1)=[[0,0,0,1],[1,1,0,1]]
screen(0)(0)=[1,1,1,1]
screen(0)(1)=[1,0,0,1]
screen(1)(0)=[0,0,0,1]
screen(1)(1)=[1,1,0,1]
screen(1)(0)(1)=0
screen(1)(0)(3)=1
I discovered this while playing in the console and though i would share the knowledge as i havent ever seen arrays like this before.
Arrays can be embedded!
Example:
row1=[[1,1,1,1],[1,0,0,1]]
row2=[[0,0,0,1],[1,1,0,1]]
screen=[row1,row2]
or
screen=[[[1,1,1,1],[1,0,0,1]],[[0,0,0,1],[1,1,0,1]]]
Results:
screen(0)=[[1,1,1,1],[1,0,0,1]]
screen(1)=[[0,0,0,1],[1,1,0,1]]
screen(0)(0)=[1,1,1,1]
screen(0)(1)=[1,0,0,1]
screen(1)(0)=[0,0,0,1]
screen(1)(1)=[1,1,0,1]
screen(1)(0)(1)=0
screen(1)(0)(3)=1
I discovered this while playing in the console and though i would share the knowledge as i havent ever seen arrays like this before.
- ags131
- Posts: 71
- Joined: Thu Oct 29, 2009 4:14 pm
Re: [THYME]Arrays
You can even embed embedded arrays. or you could embed embedded embedded arrays
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: [THYME]Arrays
An array is a list. Instead of having multiple variables you could use one as an array.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: [THYME]Arrays
The name for this is multi-dimensional arrays.
- isaacwaller
- Posts: 9
- Joined: Fri Dec 25, 2009 12:11 am
- Location: Canada
7 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests