# Tag Info

1 vote

### How to select 2 pairs of distinct twins form a list of 4-tuples?

data = Tuples[Range @ 6, 4]; Using Cases with OrderlessPatternSequence ...
• 75.1k
1 vote

...
• 75.1k

### How to retrieve the index of a subset in Subsets[list,nspec,{s}]?

You can use Combinatorica Package by evaluating (without "") "<<Combinatorica". Then use RankKSubset like so: ...
• 18.9k
1 vote

### Take elements from a list based on two criteria

list = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}, {1, (1 + I)/Sqrt[2]}}; A variant of 1066's answer using Cases ...
• 75.1k
1 vote

### Sublist pattern matching

list = {{1, 2, 3}, {1, 2, 3}, {1, 2, 2, 3}, {1, 3, 3, 5}}; Using SequenceSplit (new in 11.3) ...
• 75.1k

### Extract result of Reap in a natural way no matter if it's empty

Sow the magic disappearing list element Nothing as the first thing in the Reap block: ...
• 13.8k

Using Pick ...
• 101

### Is there a simple way to generate a non-uniformly divided interval according to an arbitrary division function?

To explain the idea, we first do the opposite of what you want. We get a high density of points where ndivFunc is small and low density where ndivFunc is high, we integrate ndivFunc. This gives a ...
• 52.7k
1 vote

### Multiple calculations in a condition

A pedestrian answer with the two interpretations: ...
• 61.6k

### Multiple calculations in a condition

list = {1, 2, 3, 82, 84, 1}; p = Position[list, x_ /; x > 3] {{4}, {5}} Erase <= 3 ...
• 75.1k

### Removing lists with zero at any position

list = Tuples[Range[-2, 2], 2]; Using Pick and ContainsNone (new in 10.2) ...
• 75.1k
1 vote

### Appending to sublists using "anchor" values

Using GroupBy and Splice (new in 12.1) ...
• 75.1k

### Constructing a list

array = {{1, 2, 3, 4, 5}, {5, 6, 7, 8, 9}, {9, 10, 11, 12, 13}}; Catenate@MapThread[List, {Array[List, Dimensions@#], #}, 2] &@array {{{1, 1}, 1}, {{1, 2}, 2}...
• 4,651
1 vote

### Extraction of sublists from a list

Using SequencePosition on string list ...
• 101

### Constructing a list

data = Partition[Range[9], 3]; Using ReplaceAt (new in 13.1) and Outer ...
• 75.1k
1 vote

### ListLinePlot without joined the data point

data = {{0, 0}, {0.5, 2}, {1, 5}, {2, 8.5}, {4, 10}, {0, 0}, {0.5, 4}, {1, 7}, {2, 9.5}, {4, 12}, {0, 0}, {0.5, 5}, {1, 9}, {2, 12}, {4, 18}}; Using <...
• 75.1k

### Subtract more than one array using DeleteCases

a = {9, 4, 7, 1, 5, 3, 8, 5, 7, 3, 1, 0}; b = {7, 5}; c = {8, 3}; Using Pick and FreeQ <...
• 75.1k

### How can I change elements in a matrix to a combination of other elements?

list = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}}; Using ReplaceAll ...
• 75.1k

### Extract result of Reap in a natural way no matter if it's empty

A data-set-like approach: ...
• 3,092

### Extract result of Reap in a natural way no matter if it's empty

Using the second argument of First: First[Reap[a][[2]],{}] (* {} *)
• 34.1k

### Extract result of Reap in a natural way no matter if it's empty

Rather than make assumptions about structure, I'd recommend building in your updating process to the Reap explicitly. Here are a couple of ways: 1. Use tags and a ...
• 29.2k

### Extract result of Reap in a natural way no matter if it's empty

Reap[Sow[a]; b; Sow[c]; Sow[d]; e, {_}, Splice[#2] &][[2, 1]] (* {a, c, d} *) ...
• 19.6k

### Extract result of Reap in a natural way no matter if it's empty

If you just want to make a list of sown values, how about using Flatten? ...
• 489

### Extract result of Reap in a natural way no matter if it's empty

How about defining a helper function?: Clear[fix]; fix[{a_, {b_List}}] := {a, b} fix[expr_] := expr Usage: ...
• 66.9k

### How to add zeros before and after each element in a list?

Using Splice list={0.2,0.5,0.7}; Take[Riffle[list, Splice[{0, 0}], {1, -1, 2}], {2, -2}];
• 101

### Replace elements of a list based on a function

Also: f = Table[3*k*k, {k, 1, 16}]; f^ ArrayPad[{1, 1, 1, 1, 0, 0, 0, 0}, {0, Length@f - 8}, "Periodic"] ...
• 4,651

### Replace elements of a list based on a function

f = Table[3*k*k, {k, 1, 16}]; Using SequenceCases ...
• 75.1k
1 vote

### How to substitute Table environments by a more sophisticated code

list = Range[12, 30]; Using SequenceCases ...
• 75.1k

### How to use StringJoin` in the given example?

list = {{"abc", "0000"}, {"def", "1111"}}; Using the operator form of Insert ...
• 75.1k

### Recovering indices from an expression

For expr = U[1, 3] U[1, 4] U[1, 5] U[2, 2] U[3, 1]; you can do {firstindex, secondindex} = Transpose[List @@@ List @@ expr] or ...
• 23.8k

### Recovering indices from an expression

Given, expression = U[1, 3] U[1, 4] U[1, 5] U[2, 2] U[3, 1] you could use Cases: ...
• 29.2k

### Recovering indices from an expression

Oh dear... I was working too hard. This will do it. ...
• 471
1 vote

### How do I remove parts of this data?

list = {{9.9, 0}, {"", ""}, {10.0, -21.7}, {"", ""}, {10.0, 28.5}, {"", ""}}; Using ...
• 75.1k
1 vote

### How to make an element in a list nested within a list have a default value?

list = {{{-2, -2}, 1}, {{-2, -5}, 2, 7}, {{1, 5}, 3, 9}, {{7, -7}, 4}}; Using ReplaceAll ...
• 75.1k
1 vote

...
• 75.1k

### Applying function to lists

list = {0.67, 0.89, 0.70, 0.78, 0.54}; n = 17; ...
• 75.1k

### Replacing a sub-partition (unordered list; multiset)

list = {{4, 4, 2, 2, 1, 1, 1}, {4, 4, 2, 2, 2, 1}}; A variant of 1066's answer using SequenceReplace (new in 11.3) ...
• 75.1k

### How can I construct this matrix?

n = 5; Table[RotateRight[Range[n], i], {i, 0, n - 1}] // MatrixForm ...
• 75.1k
1 vote

### List of symbols wherein position encoded by number to string

list = {{"a", 6}, {"z", 1}, {"g", 2}, {"y", 12}}; Using SubsetMap (new in 12.0) ...
• 75.1k

### Creating a new list from an existing one

data = { {{1, -1}, {2, 5}, {3, 9}, {4, 2}}, {{1, -4}, {2, 0}, {3, 11}, {4, -1}}, {{1, 3}, {2, 2}, {3, 22}, {4, 1}}, {{1, 0}, {2, 0}, {3, -5}, {4, 7}} }; ...
• 75.1k

### Finding position of non empty matrix entries

list = {{}, {1, 2}, {}, {3, 4}, {}, {}, {}}; Using Position and DeleteCases ...
• 75.1k

### Need list of unequal lengths to be paired with year

SeedRandom[0]; a = Range[1990, 1991]; b = {RandomReal[{0, 1}, 2], RandomReal[{0, 1}, 3]}; n = Length[a]; Using Table ...
• 75.1k

### Creating a conditional table

list = {7, 0, 8, 2, 1, 5, 8, 0, 6, 7}; Using FirstPosition (new in 10.0) to catch missing values 1. The 3rd parameter of ...
• 75.1k

...
• 75.1k

...
• 75.1k
1 vote

### How to create an array from all combinations of the vector components?

la = {a, b, c}; lb = {w, x, y, z}; A variant of E. Chan-López first answer using Comap (new in 14.0) ...
• 75.1k

### Get alphabetical number of characters in string

str = "abcdefghijklmnopqrstuvwxyz"; Using LetterNumber (new in 10.1) ...
• 75.1k

### Counting consecutive units in nested lists

If we look at your problem in a simplistic manner, we could see a function that increments by receiving 1 and resets by receiving 0 (like multiplying but with an increment). Since we need the result ...
• 9,319
Accepted

### Counting consecutive units in nested lists

Using LongestCommonSubsequence ...
• 4,651