- #1
Gueygel
- 4
- 0
Hi everyone,
I have to do a list made of evaluations of a certain function, but if some condition is not satisfied, then I don't want to have the corresponding evaluation in my list. So I tried:
Flatten[Table[If[condition,f,{}],{i,imin,imax}]]
"condition" is true or false depending on the value of "i". If it is not satisfied, then an empty {} is written and Flatten takes it away. But sometimes "condition" never gives True for any value of "i" between imin and imax. In that case, my list turns to be {{}}, and Flatten does nothing.
I would like either {{}} to be a zero (but just in this case, as there are other zeros due to other reasons), or something able to tell Table to skip a step if "condition" is not satisfied.
Does anyone have any idea to deal with this?
Thanks in advance!
I have to do a list made of evaluations of a certain function, but if some condition is not satisfied, then I don't want to have the corresponding evaluation in my list. So I tried:
Flatten[Table[If[condition,f,{}],{i,imin,imax}]]
"condition" is true or false depending on the value of "i". If it is not satisfied, then an empty {} is written and Flatten takes it away. But sometimes "condition" never gives True for any value of "i" between imin and imax. In that case, my list turns to be {{}}, and Flatten does nothing.
I would like either {{}} to be a zero (but just in this case, as there are other zeros due to other reasons), or something able to tell Table to skip a step if "condition" is not satisfied.
Does anyone have any idea to deal with this?
Thanks in advance!