- Code: Select all
array do_something(array i){
print(i);
return i;
}
int main(){
array A = seq(1,100);
gfor(array i, 100){
array condition = (A(i) % 5 == 0);
array exec = condition && do_something(A(i)); // execute the function do_something only if A(i) is a multiple of 5
}
return 0;
}
The above code prints all values contained in the array A. I thought with the operator &&, short circuiting applied. In other words if condition was 0 it will never even go to the second statement. Can someone please help me figure this out?