Linked Questions

0
votes
0answers
70 views

Indicate level with Replace [duplicate]

Replace[{{x^2, Sqrt[x]}, {x + 1, x - 3}}, f_[x__] -> f, 1] Level 1 of Replace works here as expected with output {List,List} ...
54
votes
9answers
3k views

Levels: how do they work?

I cannot understand how Mathematica manages levels, and so it's always a painful try-and-fail to use Flatten. Can someone please give me a very clear definition? ...
47
votes
7answers
69k views

Assign the results from a Solve to variable(s)

I understand Mathematica can't assign the results of a Solve to the unknowns because there may be more than 1 solution. How can I assign the 4 values of following result to variables? ...
46
votes
2answers
5k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
16
votes
2answers
524 views

ReplaceRepeated seemingly omits some rules

Is there a simple way in Mathematica to prevent rule reordering? Let me give an example: ...
5
votes
3answers
482 views

Determine if a variable appears in an expression or not?

Consider an arbitrary expression expr. This expression may contain arbitrary data, like integers, variables, implicit functions etc. Now, I would like to determine ...
8
votes
3answers
213 views

Prevent testing Head with ReplaceAll

I have a list of strings list. I am trying to get rid of some elements that match string pattern patt: ...
9
votes
3answers
484 views

Accumulate second elements in sublist

I want to accumulate the second elements in each sublist identified by its first element. ...
3
votes
3answers
221 views

Replace For with If in Mathematica way

I have this code: ...
3
votes
3answers
751 views

Use map on a different level

I have just started to get used to Mathematica's Map, Apply, and related functions, and I can't figure out how to do maps that require working "one level down". For example, I am currently trying to ...
4
votes
3answers
266 views

Variable partitioning of the data in the form of “list of lists”

I am looking for a way for variable partitioning of the data in the form of a "list of lists" for interpolating the imported data from excel. The data looks like: ...
1
vote
2answers
330 views

How to apply function f for each time value t, to each pixel from image, resulting in t images

I have a 2D array of complex values and I want to apply a function to every entry of the array, for every timepoint t in a list. I know how to apply my function to one entry for every time t in a list,...
1
vote
1answer
842 views

Collect and simplify both the coefficents and the matched patterns

(This is a far tighter version of a previous question I asked) The problem with Collect is that while Collect[exp, pattern, Simplify] will simplify the coefficients,...
4
votes
1answer
422 views

How to efficiently Flatten nested lists while preserving select levels? [duplicate]

I have lists of sets of variables, some in nested sub-lists: t = {{1, 2}, {3, 4}, {{5, 6}, {7, 8, 9}}} I need to flatten this list in place but preserve the sets....
5
votes
1answer
142 views

Why Cases and Select treat the List differently?

Look at these two examples: In[1]:=Select[f[i], MatchQ[_f]] Out[1]:=f[] In[2]:=Cases[f[i],_f] Out[2]:={} It seems that the Select take $f[i]$ as List, but Cases ...

15 30 50 per page