# Tag Info

Accepted

### Why doesn't b = a; f[a_] := b; f[2] return 2?

Caution The post is long. If you just want to know how to fix the code, please search "fix the code in title in 10 ways" in the page. If you want to read discussions about global/local ...
• 66.7k
Accepted

### Plotting a function containing a $\pm$ sign

Define: ( because I can ) ...
• 55.3k
Accepted

### Pattern Matching and Permutations

This is an example of solving such a task. It is divided into separate steps, which I believe are – due to quite descriptive naming conventions in Mathematica – self-explanatory. The only two ...
• 26.3k

### Why doesn't b = a; f[a_] := b; f[2] return 2?

I thinks it is pretty obvious why the first code returns a and the second 2. You can see it by comparing ...
• 18.6k
Accepted

### Function with complicated argument constraint with default value

In this case, the first : which is the shorthand of Pattern cannot be omitted (yeah n_ is ...
• 66.7k

### How to do this replacement? Match the variable, but not the function

You can replace \[Lambda][\[Theta]] with \[Lambda] first, and then replace \[Lambda] with <...
• 798
Accepted

### Unexpected result from MemberQ

The FullFormof 1/y[x] is Power[y[x],-1] Let's see what elements ...
• 36.7k

### Why doesn't b = a; f[a_] := b; f[2] return 2?

To understand what is going on you need to look at "DownValues" to see what is actually stored: ...
• 52.6k

### Plotting a function containing a $\pm$ sign

If it won't interfere with the rest of your work, you can define PlusMinus[a_, b_] := {a + b, a - b} and then ...
• 6,131
Accepted

### Pattern matching when decode Bencode. Problems with pattern name and nested pattern

I think that actually just trying to parse the input is easier than coming up with patterns that you can use in MatchQ. If the parse fails, then you know that ...
• 28.9k

### $n$-letter words with restriction

For something different using PolynomialMod ...
• 61.5k

### $n$-letter words with restriction

Instead of generating too many tuples and deleting the false ones, simply only create correct tuples. The constriction "a1 and a5 may not appear in he same word" can be interpreted as: "...
• 52.6k

### $n$-letter words with restriction

Using Select with ContainsAll Select[tuples, Not @* ContainsAll[{a1, a5}]]
• 74.1k
Accepted

### $n$-letter words with restriction

Usually in such cases, Mathematica offers a variety of different solutions. OrderlessPatternSequence ...
• 26.3k

### Pattern matching for repeated elements

list = {1, 2, 2, 2, 3, 4}; Using PositionIndex ...
• 74.1k

### Elegant and fast way to join all string sequences

list = {"a", "b", 1, 2, 3, 4, "a", 2, 2, 2, "edg", "?"}; Using SequenceReplace...
• 74.1k

### Extracting sequences delimited by two String markers from a list

list = {1, 2, 3, "Open", 3, 2, "Close", 9, 3, 4, "Open", 1, 0, "Close", 3, 5}; Using ...
• 74.1k
Accepted

### Position outputting lists which seemingly have the wrong dimension for the input array

You have Sqrt[3]/2 entries in struct. The FullForm shows that it has two ...
• 55.3k
Accepted

### Using patterns to replace the head of certain expressions

You have hit a common issue when using Times as a pattern. Observe the following: ...
• 26.3k

### How do I locate non-numbers

list = {1, 2, 3, 4, 5, 6 p6, 7 p7, 8, 9}; Using SequenceSplit (new in 11.3) ...
• 74.1k
1 vote
Accepted

### Moving all terms with dependents variable to one side of differential equation

This method just searches for terms that lack an instance of the dependent variable name and moves them to one side. It should work for PDEs as well. In condensed form: ...
• 23.7k
1 vote

### Using patterns to replace the head of certain expressions

How about using an If ? ...
• 145k
1 vote

### How to make expression-dependent replacements?

For a list of sublists of this type: ...
• 31
1 vote

### How can I remove empty lists { } from a nested list?

list = {{{1}, {2}, {1, 2}, {1, 2, 3}, {}, {}}, {{2}, {3}, {}}} Using SequenceCases ...
• 74.1k
1 vote

### How to copy with the last 1 with pattern matching method in a list?

list = {1, 2, 3, 1, 5, 8, 1, 9, 6}; Following the @eldo's idea and using SubsetReplace: ...
• 25.1k
1 vote

### How to copy with the last 1 with pattern matching method in a list?

list = {1, 2, 3, 1, 5, 8, 1, 9, 6}; p = Last @ Position[list, 1] {7} Using MapAt ...
• 74.1k

Only top scored, non community-wiki answers of a minimum length are eligible