pupu
Member
I am always very confused with the iteration functions provided by thinkscript.
If possible, I wish to use a common programming language to let me understand how Fold and CompoundValue works, and their differences (which seems very similar, if not the same).
From my understanding, the following computes the same?
CompoundValue:
Fold:
Generic Language:
Please give me some help on the above! Thank you!
If possible, I wish to use a common programming language to let me understand how Fold and CompoundValue works, and their differences (which seems very similar, if not the same).
From my understanding, the following computes the same?
CompoundValue:
Code:
def length = 2;
def x = CompoundValue(
length,
x[1] + x[2],
1
);
Fold:
Code:
def length = 2;
def x =
fold i = 1 to length
with x
do x[1] + x[2];
Generic Language:
Code:
chart_bar_number = 100;
length = 2;
output = 0;
For (index = 1; index <= chart_bar_number; index++)
{
if(index > length){
output[index] = output[index - 1] + output[index - 2];
}else{
output[index] = 1;
}
}
Please give me some help on the above! Thank you!