I have list where only zeroes and other list elements are present. How can I eliminate only zeroes?
List is generated by:
xvar = Array[x, {n + 3, m + 3}, {{-2, n}, {-2, m}}] /.
x_[i_, j_] /; j > 0 -> 0
yvar = Array[y, {n + 3, m + 3}, {{-2, n}, {-2, m}}] /.
x_[i_, j_] /; j > 0 -> 0
vars = Join[Flatten[xvar], Flatten[yvar]]
I tried:
DeleteCases[vars, 0, Infinity]
but it deleted also indices of the x and y arrays.
Then I tried:
Assuming[{x[i_, j_] != 0 /; i > 0, x[i_, j_] != 0 /; j > 0, y[i_, j_] != 0 /; i > 0, y[i_, j_] != 0 /; j > 0}, vars2 = Table[If[vars[[i]] == 0, Nothing, vars[[i]]], {i, Length[vars]}]]
But it does not work - behaves as if the assumption is not there and leaves items like ''If[x[0, -2] == 0, Nothing, vars[[i]]]'' and is also cumberstone, I need some more filtering for xvar and yvar to apply.
Pick[vars, NumericQ /@ vars, False]
$\endgroup$ – Coolwater Oct 26 '17 at 17:31