Linked Questions

0 votes
0 answers
145 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} ...
GambitSquared's user avatar
0 votes
0 answers
47 views

Understand the notion of level with apply [duplicate]

There is something I don't understand with the notion of levels with apply. I take this example : Apply[f, {{a, b, c}, {d, e}}, {2}] Mathematica answers me : <...
StarBucK's user avatar
  • 2,184
604 votes
19 answers
158k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
65 votes
10 answers
109k 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? ...
stevenvh's user avatar
  • 6,998
14 votes
3 answers
4k views

how to efficiently apply function to all pairs of a set (and collect the results)

To build a graph, I need to apply a function f[a_, b_] to all pairs of a list (3500 elements). The function itself returns a link ...
michar's user avatar
  • 363
17 votes
2 answers
640 views

ReplaceRepeated seemingly omits some rules

Is there a simple way in Mathematica to prevent rule reordering? Let me give an example: ...
whackyusername1's user avatar
7 votes
5 answers
965 views

How to Apply Functions to Lists with Many Curly Brackets?

For example, consider the list defined below. samplelist = {{{1,2,3,4}}, {{5,6,7,8}}}; How would I apply the Times operator ...
user155812's user avatar
8 votes
4 answers
713 views

Extract all Values from nested Association

Considering we have an Association: ...
Michiel van Mens's user avatar
4 votes
6 answers
2k views

Creating a third list from two given lists [duplicate]

I imported 2 lists of the form {{x1,y1}, {x2,y2}, ...} and {{x1,y'1}, {x2,y'2}, ...} into Mathematica. I want to make a ...
Shawn's user avatar
  • 41
10 votes
2 answers
359 views

Position with test for list of lists [duplicate]

Why do I get this error message? It seems to me that the level specification should have done the job. ...
Al Guy's user avatar
  • 1,630
13 votes
1 answer
355 views

Mapping on leaves

Say I have some nested structure, such as {a,{{b,c},d,{e,{f,g}}}}, and I want to apply a function $q$ to each of the leaves; that is, I want the output to be ...
rogerl's user avatar
  • 4,291
3 votes
3 answers
2k 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 ...
soandos's user avatar
  • 1,040
1 vote
2 answers
401 views

Extract all elements from a list that belong to a set or have a set element as an argument

EDIT: Added that I want to extract not only the variables from a specific set, but also functions involving variables from a specific set. Given the set ...
Martin's user avatar
  • 21
5 votes
1 answer
1k views

What do brackets around a levelspec option do?

The following code returns the first three integer elements of Sqrt[Range[100]]: ...
M6299's user avatar
  • 1,471
2 votes
5 answers
382 views

Is there a way to use Table[] without having to calculate my function twice?

I'm trying to use Table[] more to be more in the spirit of Mathematica. So for example, I might replace this piece of code: ...
F dot Floss's user avatar

15 30 50 per page