Computer Science Canada 2D Arrays, or Something? |
Author: | [Gandalf] [ Mon Jun 20, 2005 4:21 pm ] | ||||
Post subject: | 2D Arrays, or Something? | ||||
I'm just a bit confusled right now, having an exam and the sort tomorrow. Let's say I had this:
How would I add a say, bullet(2) so that I don't have to copy the whole thing and rename the new bullet to bullet2. So pretty much what I'm asking is, how would I shorten something like this:
Thanks. |
Author: | Bacchus [ Mon Jun 20, 2005 4:39 pm ] | ||||
Post subject: | |||||
Ok, now I'm a bit confusled about what you mean. Do you mean like a shorter way of making another array with the same record?
|
Author: | lyam_kaskade [ Mon Jun 20, 2005 4:40 pm ] | ||
Post subject: | |||
|
Author: | Cervantes [ Mon Jun 20, 2005 4:41 pm ] | ||||
Post subject: | |||||
Well, you can make it into a type and then create different variables:
But if you've got a flexible array of bullets, why are you making bullet and bullet2? In any case, if you must do that, you could try a 2D array.
EDIT: 2 posts got there before me. Yee-gawds! |
Author: | [Gandalf] [ Mon Jun 20, 2005 5:05 pm ] |
Post subject: | |
Ya, thanks - I was forgetting about types ![]() Quote: But if you've got a flexible array of bullets, why are you making bullet and bullet2?
Well, they're not two different bullets, they're two kinds of bullets going in different directions. |
Author: | MysticVegeta [ Mon Jun 20, 2005 6:35 pm ] |
Post subject: | |
doh! there can be a flexible array with mutiple dimension, jeez and all this time i have been sleeping ![]() |
Author: | Cervantes [ Mon Jun 20, 2005 6:53 pm ] |
Post subject: | |
I was pressured into adding that to the tutorial. Check it out ![]() |
Author: | Bacchus [ Mon Jun 20, 2005 9:38 pm ] | ||
Post subject: | |||
Even though in your Tutorial Cervantes, you list some basic rules... Like Quote: In a 2D array, if you leave one upper bounds alone, you can do whatever you want to the other bounds. That doesn't work ![]()
|
Author: | Cervantes [ Tue Jun 21, 2005 9:56 am ] |
Post subject: | |
Ooh, thanks for that, Bacchus. It's updated. ![]() |
Author: | MysticVegeta [ Tue Jun 21, 2005 11:05 am ] |
Post subject: | |
Bacchus wrote: Just create a new array (doesn't have to be flexible) and store the orginal array in that then change the dimension to 0 and back to what you want before restoring the original array's values. lol
i see i see, pretty nifty.I think the reason they cant make it 3, 3 is because turing doesnt know the flexiblility of the elements of each of the dimensions of the flexible array. |
Author: | Cervantes [ Tue Jun 21, 2005 1:07 pm ] | ||||
Post subject: | |||||
Bah! This is not so pretty!
I wanted to make a procedure of it, but it's a syntax error to do this:
Gandalf, my apologies for taking over your thread. I'll leave if you want. ![]() |
Author: | [Gandalf] [ Tue Jun 21, 2005 1:19 pm ] |
Post subject: | |
No, it's alright ![]() ![]() Besides, its nice to have a long topic! |