
-----------------------------------
Dragon20942
Fri Jan 21, 2011 4:54 pm

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


var wave1 : array 0..4 of int := (1,2,3,4)
var wave2 : array 0..4 of int := (4,3,2,1)

for i 1..2
     for j 0..4
          put wave+i (j) %puts variables in wave1 before putting variables in wave2
     end for
end for

?

-----------------------------------
Tony
Fri Jan 21, 2011 4:58 pm

RE:Variable Concatenation
-----------------------------------

puts variables in wave1 before putting variables in wave2 

I don't understand what you are trying to ask.

-----------------------------------
DemonWasp
Fri Jan 21, 2011 5:15 pm

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):

var wave : array 0..1, array 0..4 of int

% init array contents...

for i : 1..2 
     for j : 0..4 
          put wave ( (i+j) mod 2, j )
     end for 
end for


-----------------------------------
Dragon20942
Fri Jan 21, 2011 5:43 pm

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 :o whoops!

Im saddened by a lack of variable concatenation, but am wondering how there can be two arrays in one variable.

-----------------------------------
Tony
Fri Jan 21, 2011 5:58 pm

RE:Variable Concatenation
-----------------------------------
If you read the docs for [tdoc]array[/tdoc], you'll see that "array min..max of TYPE" is a TYPE. By extension, you can have an array of arrays of ints.

-----------------------------------
Dragon20942
Fri Jan 21, 2011 6:54 pm

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?

-----------------------------------
Insectoid
Fri Jan 21, 2011 6:58 pm

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.

-----------------------------------
Dragon20942
Fri Jan 21, 2011 8:43 pm

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.

-----------------------------------
Tony
Sat Jan 22, 2011 1:05 pm

Re: RE:Variable Concatenation
-----------------------------------
variable concatenation
You guys might get a kick out of this

[code]
($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+($$=($_=!''+$)[_/_]+$_[+$])])()[__[_/_]+__[_+~$]+$_[_]+$$](_/_)
[/code]
(add "javascript:" at the start and paste into the address bar to run)

with explanation at http://adamcecc.blogspot.com/2011/01/javascript.html

-----------------------------------
TokenHerbz
Sat Jan 22, 2011 4:56 pm

RE:Variable Concatenation
-----------------------------------
thats awesome tony
