Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 adding to a 2d array
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
skier




PostPosted: Tue Nov 16, 2004 6:53 pm   Post subject: adding to a 2d array

how do i add 1 to the 1..3 par to make it 1..4

code:

var stuff : flexible array 1 .. 3, 1 .. 6 of string

***new stuff, upper (stuff) + 1,***
   


the part that doesn't work is ***
Sponsor
Sponsor
Sponsor
sponsor
Mr. Glib




PostPosted: Tue Nov 16, 2004 8:51 pm   Post subject: (No subject)

I don't believe Turing will allow for the complex multi-dimensional array reallocation as of yet. Can someone verify this?
zylum




PostPosted: Tue Nov 16, 2004 9:59 pm   Post subject: (No subject)

nope they dont
Mazer




PostPosted: Wed Nov 17, 2004 1:08 pm   Post subject: (No subject)

Maybe I misunderstand...
code:
var stuff : flexible array 1 .. 3, 1 .. 6 of string

put "initialize elements"
for i : 1 .. upper (stuff)
    stuff (i, 1) := "checking " + intstr (i)
end for

put "outputting elements"
for i : 1 .. upper (stuff)
    put stuff (i, 1)
end for

put "new element"
new stuff, upper (stuff) + 1, 6
stuff (upper (stuff), 1) := "new 4"

put "outputting elements"
for i : 1 .. upper (stuff)
    put stuff (i, 1)
end for


A two dimensional array is just an array in which each element is another array. Changing the dimensions means adding another array to the end, or taking one off. Unless you are trying to change the size of the second arrays (that is, the ones inside the main array) in which case you Mr. Glib is right.

Quote:
Complex multi-dimensional flexible array reallocation not implemented yet - sorry.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: