# Tag Info

1 vote

### Measuring multiple incidences of a continuous constant in a list

Using SequenceSplit (new in 11.3) list = {{0}, {1}, {1}, {0}, {1}, {0}}; Length /@ SequenceSplit[list, {{0}}] {2, 1}

### Translate selection from one list to another

KeySelect is another possibility al = {1, 2, 3, 4, 5, 6}; bl = {a, b, c, d, e, f}; KeySelect[EvenQ] @ Thread[al -> bl] <...

### How can I determine the cycle lengths in a directed graph?

a = {{0, 1, 0, 0}, {0, 0, 1, 0}, {1, 0, 0, 1}, {1, 0, 0, 0}}; g = AdjacencyGraph[a]; Length /@ FindCycle[g, Infinity, All] {3, 4}

...

### Concise alternative to First@First@Position[..., 1,Heads->False]

Another way, is to use PositionIndex and KeySelect: ...

### Concise alternative to First@First@Position[..., 1,Heads->False]

Hats off to @eldo for the amazing work on revisiting old threads to demonstrate commands in newer versions. I think it's very beneficial for all. Some more fun stuff With the list ...

### Concise alternative to First@First@Position[..., 1,Heads->False]

If we don't have negative numbers (thank you 1066) we can use PositionLargest (new in 13.2) ...

### How to implement JoinTo efficiently?

We can also use ApplyTo (new in 12.2) together with Splice (new in 12.1): ...

### Taylor approximation of integrals

I found one scheme that converges, but with not very high accuracy. Note that increasing the number of terms of the series and the number of iterations does not reduce the error. It is possible that ...
1 vote

### Selecting positive real numbers from a list?

list = {1, 11.2, -12, a, 10 + I}; You can use DeleteCases as follows: ...
1 vote

### Selecting positive real numbers from a list?

list = {1, 11.2, -12, a, 10 + I}; If we treat 1 as as a real number, we can use ...
1 vote

### Count consecutive occurrences in a list above a certain value

Using SequenceSplit which came with V 11.3 Length /@ SequenceSplit[data, {x_ /; x < 100}] {3, 2} ...
1 vote

Using Cases: ...

### Taylor approximation of integrals

There are some typos in your equations if what you want to reproduce is table 2 and figure 1. In particular the alpha parameter is 20, not 0.2, the ...
1 vote

### How to efficiently Append a result of an operation on each element of a list to itself?

lst={{x1, y1, z1}, {x2, y2, z2},{x3,y3,z3}} MapThread[Append,{#,#[[All,2]] #[[All,3]]}]&@lst (*{{x1,y1,z1,y1 z1},{x2,y2,z2,y2 z2},{x3,y3,z3,y3 z3}} *) ...

1 vote

### Manipulate list of equations

eqns = {a/b == c, d/e == f, x/y == z}; eqns /. u_/v_ == w_ -> u == w*v (* {a == b c, d == e f, x == y z} *) Have fun!
1 vote

### How to efficiently Append a result of an operation on each element of a list to itself?

This is basically the same as Rojo's idea, but it appears to be 10% faster on my system (M1 Max): ...

### How to efficiently Append a result of an operation on each element of a list to itself?

list = {{a, b, c}, {e, f, g}}; Splice came with V 12.1 ...

### Accumulated instance count of each list element

Another way using PositionIndex and ReplacePart: ...

### Accumulated instance count of each list element

Just more variations... ...

### Accumulated instance count of each list element

list = {m, i, s, s, i, s, s, i, p, p, i}; Permute[Flatten[Ordering /@ Split@Sort@#], Ordering@#]&@list (* {1, 1, 1, 2, 2, 3, 4, 3, 1, 2, 4} *)

...

### Accumulated instance count of each list element

Using an Association - counter: ...

### How to add a column to a dataset made up of an association of associations?

ds[All, Module[{$c = 0}, <|"ID" -> ++$c, #|> &]] ...

### How to add a column to a dataset made up of an association of associations?

You can add items using Prepend/Append like e.g. to add an ID number: c = 1; ds = Prepend[#, ID -> c++] & /@ baseDeDatos Note that MMA now displays the ...

### Accumulated instance count of each list element

accumulateCounts := Module[{c$}, c$[_] = 0; Map[PreIncrement@*c\$]] accumulateCounts @ {m, i, s, s, i, s, s, i, p, p, i} ...

### Manipulate list of equations

MultiplySides[#,Denominator[First@#],Assumptions->Denominator[First@#]>0]&/@eqns (*{a ==b c, d == e f, x == y z} *)

### Manipulate list of equations

One of the ways is as follows. eqns = {a/b == c, d/e == f, x/y == z}; Map[#[]/#[[1, 2]] == #[]/#[[1, 2]] &, eqns] ...
Accepted

...

### How to remove a high accuracy numerical number from a list?

Using Cases and FractionalPart: ...

### How to remove a high accuracy numerical number from a list?

Not very elegant, but since you explicitly mention that you want to remove 0.2499999999999992 ...

### How to remove a high accuracy numerical number from a list?

list = {-0.36, 0.2499999999999992, -0.21, 0.36, 0.36} Delete[list, Position[Round[list, 0.01] - list, Except[0.], {1, ∞}, Heads -> False]] {-0.36, -0.21, ...

### Finding position of the maximum value of each subset

We could also use TakeLargest ...

### Easier way to input Dynamic matrix?

This Exemple calculate Dynamicly a Determinant with PopupMenu: ...
1 vote

### Comparing Positions of Elements in a List

Using Mr. Wizard's data: list = Characters @ "xdslkridiatjxzyoedem"; we can use PositionIndex to our advantage ...
1 vote

### Ordering function with recognition of duplicates

Using Association - related functions (which were not available at the time the question was posted): ...

### Subtracting second columns of two matrices

Using Transpose and MapAt: ...
1 vote

...

Using Cases: ...

### Retrieving duplicates from nested list

Using some functions which were not availabe at the time the question was posed ...

### Selecting a sublist based on Length

We could also use TakeLargestBy list = {{1, 2}, {4, 5, 6, 7}, {5, 4, 3}}; Take the largest list by length: ...

### How do I check if any element in a list is positive?

A point-free style {-1, -1, 1} // AnyTrue[Positive]

### How do I check if any element in a list is positive?

Since V 10.0 we can also use AnyTrue: AnyTrue[{-1, -1, 1}, # > 0 &] True ...
1 vote

### Counting the population of integers

This has a lot of answers already, but here's an obvious (to me) solution that hasn't been mentioned: ...

### Counting the population of integers

Another possibility: ...

### Neglecting coefficients of a given list

Clear["Global`*"]; exp1 = a1*a2*24 + a1*a2*a3*kk*25 + a1*a2^2 + a1*a2*a3*34; DeleteCases[List @@ exp1, _?NumericQ | kk, {2}] {a1 a2, a1 a2^2, a1 a2 a3, ...
1 vote

### Numbering element in descending order

Since V 12.0 there is OrderingBy: m = {{1, 5}, {2, 8}, {3, 9}, {4, 2}, {5, 9}, {6, 7}, {7, 9}, {8, 10}, {9, 5}, {10, 2}}; Ordering @ OrderingBy[Last] @ m {3, 6, 7,...