I am trying to create a list of conditions using Table[]
in the following way:
Range[100]/.Table[t_ /; t > k && Mod[t, k] == 0 -> "",{k,2,10}]
but the result does not change the index value k from 2 to 10.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityInject table iterator values into held expressions with With
:
Range[100] /.
Table[With[{k = k}, t_ /; t > k && Mod[t, k] == 0 -> ""], {k, 2, 10}]
(*
{1, 2, 3, "", 5, "", 7, "", "", "", 11, "", 13, "", "", "", 17, "", \
19, "", "", "", 23, "", "", "", "", "", 29, "", 31, "", "", "", "", \
"", 37, "", "", "", 41, "", 43, "", "", "", 47, "", "", "", "", "", \
53, "", "", "", "", "", 59, "", 61, "", "", "", "", "", 67, "", "", \
"", 71, "", 73, "", "", "", "", "", 79, "", "", "", 83, "", "", "", \
"", "", 89, "", "", "", "", "", "", "", 97, "", "", ""}
*)
See "Possible Issues" in the docs for Table
(second-to-last example group).