# Tag Info

Accepted

### Association vs Pair - Creation performance, Selection performance

Simply use keys = Range[1000000]; vals = Range[1000000]^2; result = Pick[vals, PrimeQ[keys]]; to get the best of both worlds (zero construction cost and even ...
• 94.9k
Accepted

...
• 51.5k

### How can I use variables instead of slots in DeleteCases?

Pick could also be useful: Pick[tuples, Function[{a, b, c}, a + 2 b + c == 0] @@@ tuples, False]
• 5,089

### How can I apply a function only to even-index elements of a list?

I changed D to Dd: MapAt[Dd, A, 2 ;; ;; 2]
• 3,792
Accepted

### Why does this Fourier transform not match the formula?

I think the confusion is between frequency in cycles per second or Hz and frequency in radians per second. In the page you link to the frequency is in Hz. Thus to match this convention the ...
• 14.7k

### How can I apply a function only to even-index elements of a list?

You can use the new ApplyTo: A = {1, 2, 3, 4, 5}; Dd[P_] := P + 1 A[[2 ;; ;; 2]] //= Dd; A (* {1, 3, 3, 5, 5} *)
• 35.6k

### Find shortest distance between two functions

Assuming that you mean the shortest distance between their graphs, the following does the job. ...
• 16.7k
Accepted

### How to use PlusMinus properly?

Per the documentation, you could define the function for PlusMinus: ...
• 19.3k

### How can I apply a function only to even-index elements of a list?

alist = {1, 2, 3, 4, 5} Using MapIndexed: ...
• 14.9k

### How can I use variables instead of slots in DeleteCases?

g[{a_, b_, c_}] := a + 2 b + c == 0 Using the operator form: DeleteCases[x_ /; g[x]][tuples]
• 14.9k

### How can I use variables instead of slots in DeleteCases?

Perhaps (Thanks to comment/correction @BenIzd ) DeleteCases[tuples, _?(Apply@Function[{a, b, c}, a + 2 b + c == 0])] is what you are looking for?
• 36.4k
Accepted

### While inside a function body does not work as expected

You may wish to disambiguate your description as it seems you're creating rational functions made up of polynomials. Below I modularized CreateDiscontinuityPoly ...
• 1,084

### How to simplify function with Abs?

Try this: Refine[Simplify[mylist], Assumptions -> x \[Element] Reals]
• 3,768

### How can I apply a function only to even-index elements of a list?

Using Position and Map: ...
• 3,768

### How can I apply a function only to even-index elements of a list?

SubsetMap[dd, arr, 2 ;; -1 ;; 2] (* {1, 3, 3, 5, 5} *) where: arr = {1, 2, 3, 4, 5}; dd[p_] := p + 1 Just for fun ...
• 10.3k
Accepted

### How to simplify function with Abs?

PiecewiseExpand does it. Edit and // ComplexExpand // Simplify does it ...
• 15.2k

### Why Mathematica does not return explicit output

You need to be careful about the precedence of each operation. Here's your original: A = ({{a11, a12}, {a21, a22}}) // Transpose[A] // MatrixForm Here is how the ...
• 3,792
Accepted

### Introduce formal symbols indexed by natural numbers

It is often useful to avoid Subscript, Superscript, and Subsuperscript and instead to just ...
• 120k

### How to simplify function with Abs?

Here's the ComplexityFunction way I referred to in my comment just to illustrate the alternative: ...
• 213k

### Find shortest distance between two functions

Assuming that you mean by "shortest distance" the x value and y values where both functions differ by a minimal amount. In this case the distance is given by the difference of the two ...
• 24.3k
Accepted

### Classifying elements, by the value of a fixed function, using Replace

L = Table[ConstantArray[1, RandomInteger[999]], 100000]; m = Replace[L, {x_List :> Quotient[Length@x, 100]}, {1}]; \{7,2,8,8,6,5,1,5,2,1,1,3,6,7,2,4,7,2,1,8,...
• 14.9k
Accepted

### Replacement, PatternTest, Module related Question

The reason your attempt fails is that at the time the Function is applied to its arguments, m has not yet been replaced by ...
• 23.4k
Accepted

### Tropical Operation Conversions: Multiple Operations

I assume that you want to replace Addition by "Max" and Multiplication by addition. It is not clear how a negative term should be treated. For the time being I assume that it will be ...
• 24.3k
Accepted

### Module returns multiple functions

The correct syntax is: prep[p1_, p2_] := Module[{}, f1[x_, y_] := (p1 + p2)*x + y; f2[x_, y_] := (p1 - p2)*x - y; {f1, f2}]; Then: ...
• 24.3k
Accepted

### How to get a function from a string?

Welcome to the community. With little generalization (be applied to any variable name), Here is how you can achieve your goal: Since Function has ...
• 5,089

### Tropical Operation Conversions: Multiple Operations

I'm not entirely sure if this is what you're looking for, but it seems you would just need to replace your x_ with x__ ...
• 2,843
Accepted

### RunProcess : Save directly to Mathematica Variable

It might be possible to do what you say, if myprogram.exe can output the image data directly to stdout. But I wouldn't lose any sleep over having to create a ...
• 62.7k

### Generating a list of pure variables

A variation on J.M.'s approach using PadRight: ...
• 349k