# Tag Info

## Hot answers tagged conditional

### Make a list of the first 100 primes, keeping only ones whose last digit is less than 3

SolveValues[x <= Prime[100] && Mod[x, 10] < 3, x, Primes] ...
• 396k
Accepted

### Confused about If statement

Translation to make it easier to see. When you write If[n1 == 0, n2 == 1] This translates to ...
• 145k
Accepted

### Make a list of the first 100 primes, keeping only ones whose last digit is less than 3

Well, since the cat's out of the bag, I guess we can proceed with our race-toward-ten. I'll provide a point-free solution to the original problem and avoid the OP's question about the specific ...
• 28.9k

### Problem with If statement

masters = {C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0], C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 2, 0, 0]}; C18 is an undefined function. ...
• 159k
Accepted

### Condition inside pure function

As supplement of @MichaelE2's comment. Condition is bit of "meta" in the sense that it will only be absorbed by specific functions with pattern matching ...
• 2,263

### Make a list of the first 100 primes, keeping only ones whose last digit is less than 3

Expanding on my comment (first method) 1. Select[Prime[Range[100]], Mod[#, 10] < 3 &] here are two more (kind of cheating because 2 is an exception) 2. <...
• 3,810
Accepted

### Which NDSolve method is most effective for the given chaotic system?

We don't know what method is most efficient, since to answer this question we need too much test performed. We can only suggest code without some NDSolve messages ...
• 45k

### Make a list of the first 100 primes, keeping only ones whose last digit is less than 3

Another option using what the question asks, which is to use f[#] p = Prime[Range[100]] ...
• 145k

### Adapt elements in the list, condition by condition

box[1, 1] = {{4.4, {1, 1}, {a}}, {1.5, {1, 1}, {a}}, {10.8, {2, 1}, {3 a}}, {10, {1, 3}, {4 a}}}; box[1, 1] /. {{a} -> {1}, a -> .1} ...
• 396k
Accepted

### How to check if the given row matches one of the rows of a table?

tabb = RandomInteger[{0, 4}, {5, 4}]; row = RandomInteger[{0, 4}, 4]; Well, it's simply MemberQ[tabb, row] returning ...
• 74.1k

### Make a list of the first 100 primes, keeping only ones whose last digit is less than 3

Just to illustrate Sow and Reap ...
• 61.5k
Accepted

### SetDelayed assignment not producing expected result when using ReplaceAll

Well, the simplest thing to do would be to use Equal instead of SameQ: test[k_, x_] := If[k == 0, x, x^2] It would also work to put a constraint on your argument ...
• 28.9k

### SetDelayed assignment not producing expected result when using ReplaceAll

See Operator Precedence in Tech Note Operator Input Forms test[k_, x_] is evaluating before the ReplaceAll. In ...
• 42.3k

### How to check if the given row matches one of the rows of a table?

SeedRandom[1]; tabb = RandomInteger[{0, 4}, {5, 4}] row = {0, 3, 4, 4} ContainsAny[tabb, {row}] True
• 55.3k

### How to check if the given row matches one of the rows of a table?

Another alternative is to use Union: ...
• 25.1k

### Pattern matching vs. condition in a function

For g4, your condition doesn't evaluate to True or False. Specifically, ...
• 28.9k

### How to highlight top N elements in each table column?

As an example in: Using Highlighted and Ordering: ...
• 55.3k
Accepted

### Evaluation control of nested With, If and Integrate

After a second thought I retract my vote for duplicate because the relevance is probably not so obvious at least for beginners, but do remember this post is essentially duplicate of the following: Why ...
• 66.7k

### Evaluation control of nested With, If and Integrate

Evaluation process in Mathematica can be tricky at the beginning; I suggest reading the tutorial on the Evaluation of Expressions. The problem you are facing is that both ...
• 26.2k

### Modify list elements if last two entries are equal

list = {{1, 1, 1, 1, 1, 3}, {1, 1, 3, 4, 1, 1}}; Using SequenceReplace (new in 11.3) and ...
• 74.1k

### Removing "spikes" in data

data = Table[Evaluate @ Re @ FourierSeries[t^5, t, 4], {t, -3. Pi, 3. Pi, 6. Pi/128}]; Using GaussianFilter ...
• 74.1k

### Check an input matrix M contains any nonzero diagonal matrix element or not

p = {{-1, 1, 1}, {2, 0, 2}, {3, 3, 1}}; q = {{0, 1, 1}, {2, 0, 2}, {3, 3, 0}}; 1. Using AllTrue with ...
• 74.1k

### Using "If" statement to change a list values

Function[{x,y},If[x<60,y+20,y],Listable][Sample,Sample2] (* {25,10,35,20} *)
• 19.3k

### Extracting data from a table under conditions

Using kglr's data: tb1 = {{0, 3}, {0, 0}, {1, 3}, {2, 0}, {2, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 0}, {3, 3}}; Another way, using ...
• 25.1k

### Extracting data from a table under conditions

Some other possibilities Using kglr's data: list = {{0, 3}, {0, 0}, {1, 3}, {2, 0}, {2, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 0}, {3, 3}}; Predefine ...
• 74.1k

### SetDelayed assignment not producing expected result when using ReplaceAll

Okay, first I'll acknowledge @att's comment. Using Unevaluated is probably the most aligned with what you were trying to achieve with your original code. Maybe I'm ...
• 28.9k

### How to check if the given row matches one of the rows of a table?

tabb = { {1, 0, 4, 0}, {4, 1, 2, 1}, {0, 3, 3, 4}, {2, 0, 4, 1}, {3, 0, 3, 4}}; row = {2, 0, 4, 1}; Three more simple methods ...
• 74.1k
Accepted

### How to check if at least one ordering of the given row matches one of the rows of a table?

MemberQ[Sort /@ tabb, Sort[roww]]
• 26.2k