232 views

### Confusion over blank sequence in pattern matching

My overall goal was to produce a list of heads used in a graphics output. For an example I used: ...
223 views

### How to make Simplify/Expand work in patterns?

I am trying to calculate deriv of a complicated function and store the values for reuse. But the FullSimplify in my definition doesn't seem work all the time: ...
1k views

...
43 views

### Replacing with Elements from a List [duplicate]

I have a fairly complicated expression with nested lists and I want to substitute a given string for each integer. Here's a simple example where ind is my integer-valued data structure and names is ...
115 views

### How to use EvenQ[] in patterns? [duplicate]

This works: (w[1] + w[2] + w[3]) /. w[s_] -> If[s == 2, w[s], 0] (* w[2] *) This doesn't: ...
132 views

### Sum of Sequence inside a replace rule? [duplicate]

I'd like a replacement rule that replaces derivatives with their total order. I tried ReplaceAll[Derivative[x__] -> Plus[x]][Derivative[1, 1]] but it doesn't ...
74 views

### What's wrong with my rule? [duplicate]

Consider a simple code to form a SparseArray: Q = 5; a = Table[i, {i, Q}]; SparseArray[{{j_} /; j > 2 -> a[[j]]}, {Q}] Part::pspec: Part specification j ...
59 views

### pattern matching and applying a function, not working as expected [duplicate]

Consider the following code G[x, y] /. a_[b__] -> Total[a @@@ Permutations[List[b]]] I expect it to give G[x, y]+G[y,x] ...
41 views

### Replace date pattern [duplicate]

I have a list, such as the following: li = {"2017-10-16", 10.24, 10.71, 10.18, 10.61, 10.61, 16802200} Extracting the first element ...
202 views

### Problem in evaluating nested anonymous functions [duplicate]

It seems that I have found a bug (or a fundamental problem in the design of the programming language of Mathematica) with functions defined as rules. Define the function g as g(1)=2 and g(2)=1. We can ...
35 views

### Puzzling transformation rule output [duplicate]

My problem should be a trivial one but for the life of me I can't get it to work. This is my data (10 rows, each made up of a DateList and a list of 5 numeric values corresponding to that date); <...
16 views

### KeyAbsent when using Association in a replacement [duplicate]

I am trying to replace derivatives with other functions. I expected as = Association[fx -> dfx] Derivative[1][fx][x] /. Derivative[1][y_][_] -> as[y] to ...
20 views

### How to define a function that utilizes the Range function? [duplicate]

How can I define a function that uses the Range function in its definition. A very simple example would be f[x_]=Range[x] However if I try that it outputs "Range ...