# Tag Info

1 vote

...
• 27.6k

...
• 27.6k

...
• 81.2k
1 vote

...
• 81.2k
1 vote

...
• 81.2k

### MatchQ returns False for a match for e1 ** e2 while matching both e1 and e2

Using RealValuedNumberQ (new in 13.3) MatchQ[(2 e1) ** (-2 e2), (k1_?RealValuedNumberQ x_) ** (k2_?RealValuedNumberQ y_)] True ...
• 81.2k

### Replace a column/row of a matrix under a condition by a random number

m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; Using Cases ...
• 81.2k
1 vote

### What is the correct pattern to DeleteCases from a list?

DeleteCases require a pattern to remove elements removes all elements of expr that match pattern. in your examples, ...
• 10.1k
1 vote

...
• 27.6k
1 vote

### Replace elements that do not match a pattern

mat = {{0, a, b}, {c, 0, d}, {0, 0, e}}; A hash-free variant of E. Chan-López answer using SameAs (new in 13.1) ...
• 81.2k
1 vote

...
• 81.2k
1 vote

### Replace elements that do not match a pattern

mat = {{0, a, b}, {c, 0, d}, {0, 0, e}}; Using ReplaceList: ...
• 27.6k

### Replace elements that do not match a pattern

mat = {{0, a, b}, {c, 0, d}, {0, 0, e}}; Using MapCases by Richard Hennigan (Wolfram Research) ...
• 81.2k

### Removing lists with zero at any position

Create and select tuples in one step with SelectTuples by Sander Huisman: ...
• 81.2k

### Create sublists whose totals exceed a certain threshold and that are as short as possible

split[lst_, th_] := Module[{t = 0}, Split[lst, Or[(t += #) <= th, t = 0] &]]; Examples: ...
• 399k
1 vote

### Create sublists whose totals exceed a certain threshold and that are as short as possible

Other way with AppendTo : list = {2, 1, 8, 10, 1, 4, 4, 5, 3, 4, 4, 11, 12}; th = 10; t=s={};(AppendTo[t,#]; If[Total[t]>th,AppendTo[s,t]; t={}])&/@list;s ...
• 774

### Removing lists with zero at any position

list = Tuples[Range[-2, 2], 2]; Another way using GroupBy: ...
• 27.6k
1 vote

### Is there a better way to " Select non self mapping elements from a list of rules"?

abc = {a -> a, b -> c, d -> d, e -> f}; Another way using GroupBy: ...
• 27.6k
1 vote

### Find subsequences of consecutive integers inside a list

list = {3, 4, 5, 6, 7, 10, 11, 12, 15, 16, 17, 19, 20, 21, 22, 23, 24,42, 43, 44, 45, 46}; Using SequenceSplit and ...
• 27.6k

### Find subsequences of consecutive integers inside a list

list = {3, 4, 5, 6, 7, 10, 11, 12, 15, 16, 17, 19, 20, 21, 22, 23, 24, 42, 43, 44, 45, 46}; Using FindRanges by Jan Pöschko (Wolfram Research) ...
• 81.2k
1 vote

### Create sublists whose totals exceed a certain threshold and that are as short as possible

list = {2, 1, 8, 10, 1, 4, 4, 5, 3, 4, 4, 11, 12}; th = 10; A more programmatic way to do it is the following: ...
• 27.6k

### Create sublists whose totals exceed a certain threshold and that are as short as possible

list = {2, 1, 8, 10, 1, 4, 4, 5, 3, 4, 4, 11, 12}; th = 10; f = SequenceCases[#, {a___, e_} /; ! Max@Accumulate@{a} > th :> {a, e}] &; f@list ...
• 5,021

### Create sublists whose totals exceed a certain threshold and that are as short as possible

I may have misunderstood but this finds shortest subset satisfying constraint: ...
• 62.8k
Accepted

### Create sublists whose totals exceed a certain threshold and that are as short as possible

Why not just use Most: ...
• 4,587

### Create sublists whose totals exceed a certain threshold and that are as short as possible

Assume what you want is just one instance of shortest consecutive sequence of the elements in the list. Then following pattern matching will help you: ...
• 1,460

### Is there a better way to " Select non self mapping elements from a list of rules"?

DeleteCases[abc, Rule[x_, x_]] {b -> c, e -> f}
• 1,460

### Is there a better way to " Select non self mapping elements from a list of rules"?

abc = {a -> a, b -> c, d -> d, e -> f}; Using Pick and UnsameQ ...
• 81.2k