Computer Science Canada Variable Concatenation |
Author: | Dragon20942 [ Fri Jan 21, 2011 4:54 pm ] | ||
Post subject: | Variable Concatenation | ||
I'm just wondering if one can concatentate variables in Turing. say if I wanted to cycle through wave1 - wave2 with a for loop, could I somehow
? |
Author: | Tony [ Fri Jan 21, 2011 4:58 pm ] |
Post subject: | RE:Variable Concatenation |
Quote: puts variables in wave1 before putting variables in wave2 I don't understand what you are trying to ask. |
Author: | DemonWasp [ Fri Jan 21, 2011 5:15 pm ] | ||||
Post subject: | RE:Variable Concatenation | ||||
What you're asking about is typically called "variable variables", and while this feature occurs in a lot of scripting languages and "build languages", it's not common in "programming languages", like Turing. Turing does not possess this feature. A "variable variable" is a (string) variable that contains the name of another symbol, which can then be evaluated to the value of the named variable. An example (looks like Turing but is NOT valid Turing):
Your example could be rewritten as:
|
Author: | Dragon20942 [ Fri Jan 21, 2011 5:43 pm ] |
Post subject: | RE:Variable Concatenation |
I was just asking if wave+i could be used as a concatenated variable with i still a functioning variable, thus outputting the values in wave1 and then outputting the varibles in wave2. Oh and I made an error in declaring the arrays ![]() Im saddened by a lack of variable concatenation, but am wondering how there can be two arrays in one variable. |
Author: | Tony [ Fri Jan 21, 2011 5:58 pm ] |
Post subject: | RE:Variable Concatenation |
If you read the docs for array, you'll see that "array min..max of TYPE" is a TYPE. By extension, you can have an array of arrays of ints. |
Author: | Dragon20942 [ Fri Jan 21, 2011 6:54 pm ] |
Post subject: | RE:Variable Concatenation |
Ok, so each element in the "first array" has a "second array" in it, all of it being in one variable? That is interesting. Is record the only way to stuff more than one array into another? |
Author: | Insectoid [ Fri Jan 21, 2011 6:58 pm ] |
Post subject: | RE:Variable Concatenation |
I record is convenient for storing multiple related variables of different types in an organized manner. Your program should be fine with a 2D array. |
Author: | Dragon20942 [ Fri Jan 21, 2011 8:43 pm ] |
Post subject: | RE:Variable Concatenation |
Ok I was just wondering because I had originally planned to do variable concatenation, but ended up doing records instead. My program has since become a whole lot more complicated and anything other than a record would have made it less efficient. "wave" now has 14 arrays and 2 arrays of arrays within it. |
Author: | Tony [ Sat Jan 22, 2011 1:05 pm ] | ||
Post subject: | Re: RE:Variable Concatenation | ||
Dragon20942 @ Fri Jan 21, 2011 8:43 pm wrote: variable concatenation
You guys might get a kick out of this
(add "javascript:" at the start and paste into the address bar to run) with explanation at http://adamcecc.blogspot.com/2011/01/javascript.html |
Author: | TokenHerbz [ Sat Jan 22, 2011 4:56 pm ] |
Post subject: | RE:Variable Concatenation |
thats awesome tony |