Discuss Scratch

Blaze349
Scratcher
1000+ posts

Arrays to list

Does anyone know of a converter that converts arrays to list.
fezzinate
Scratcher
100+ posts

Arrays to list

Not sure if I understand. In scratch a list is an array.
Zro716
Scratcher
1000+ posts

Arrays to list

fezzinate wrote:

Not sure if I understand. In scratch a list is an array.
I think he means converting a multi-dimensional array to a Scratch list (one-dimensional).

In that case I happen to have a simple formula for finding out the multi-dimensional position on a one-dimensional list:
define get item (a)(b)(c) . . . of list
set [item v] to (item ((a) + (((a-size) * ((b) -(1))) + (((a-size) * (b-size)) * ((c) - (1))))) of [list v])
Hopefully you get the idea that with each dimension the dimensions before it are multiplied together.
Blaze349
Scratcher
1000+ posts

Arrays to list

Zro716 wrote:

fezzinate wrote:

Not sure if I understand. In scratch a list is an array.
I think he means converting a multi-dimensional array to a Scratch list (one-dimensional).

In that case I happen to have a simple formula for finding out the multi-dimensional position on a one-dimensional list:
define get item (a)(b)(c) . . . of list
set [item v] to (item ((a) + (((a-size) * ((b) -(1))) + (((a-size) * (b-size)) * ((c) - (1))))) of [list v])
Hopefully you get the idea that with each dimension the dimensions before it are multiplied together.
Never mind I wanted to convert a 1-D array(with commas) to a scratch list (without commas). I figured it out now.
forth
Scratcher
15 posts

Arrays to list

Zro716 wrote:

fezzinate wrote:

Not sure if I understand. In scratch a list is an array.
I think he means converting a multi-dimensional array to a Scratch list (one-dimensional).

In that case I happen to have a simple formula for finding out the multi-dimensional position on a one-dimensional list:
define get item (a)(b)(c) . . . of list
set [item v] to (item ((a) + (((a-size) * ((b) -(1))) + (((a-size) * (b-size)) * ((c) - (1))))) of [list v])
Hopefully you get the idea that with each dimension the dimensions before it are multiplied together.

Thanks, i like your post at the right time! Look at the germans: http://scratch.mit.edu/discuss/post/322996
BlazeStudios
New Scratcher
5 posts

Arrays to list

Zro716 wrote:

fezzinate wrote:

Not sure if I understand. In scratch a list is an array.
I think he means converting a multi-dimensional array to a Scratch list (one-dimensional).

In that case I happen to have a simple formula for finding out the multi-dimensional position on a one-dimensional list:
define get item (a)(b)(c) . . . of list
set [item v] to (item ((a) + (((a-size) * ((b) -(1))) + (((a-size) * (b-size)) * ((c) - (1))))) of [list v])
Hopefully you get the idea that with each dimension the dimensions before it are multiplied together.
Thanks

Powered by DjangoBB