Right now, I’ve been trying
threshold[min_,max_]=Apply[Select[EvenQ],Range[min,max]
However, that’s not working. It seems extremely difficult to create a list and change it in one go.
Right now, I’ve been trying
threshold[min_,max_]=Apply[Select[EvenQ],Range[min,max]
However, that’s not working. It seems extremely difficult to create a list and change it in one go.
There are many ways to do this you can try:
Clear[threshold];
threshold[min_, max_] := DeleteCases[Range[min, max], _?OddQ]
Well I am not very smart, see my photo, but that is interesting. I know it is a shot list and I guess zero is even so being very discrete . . .
In[3]:= n := 0
In[6]:= Case[{n, n + 1}, n]
Out[6]= Case[{0, 1}, 0]
wait . . .
In[3]:= n := 0
In[7]:= Case[{n, n + 1}, n + 1]
Out[7]= Case[{0, 1}, 1]
why did this work, or in other words, what does this tell the interpreter to do that was different from how I typed it? Why was “:=” better than “=”? and what is “_?”? Thanks for the answer!
Apply replaces the Head of an expression. Changing the Head to Select[EvenQ] results in this Select[EvenQ][1, 2, 3, 4, 5] which is invalid. You need this
threshold[min_, max_] := Range[min, max] // Select[EvenQ]