Linked Questions

536
votes
19answers
135k 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 ...
187
votes
2answers
10k views

What is the distinction between DownValues, UpValues, SubValues, and OwnValues?

When reading through the documentation, you often encounter the phrases DownValues, UpValues, ...
184
votes
3answers
41k views

Alternatives to procedural loops and iterating over lists in Mathematica

While there are some cases where a For loop might be reasonable, it's a general mantra – one I subscribe to myself – that "if you are using a ...
91
votes
6answers
88k views

How do I clear all user defined symbols?

Is there some way to do this other than going to Evaluation -> Quit kernel and firing a new one up?
89
votes
5answers
11k views

What does the construct f[x_] := f[x] = … mean?

This question mentions "x := x = trickery". What does defining a function as f[x_] := f[x] = ... do and what is it good for?
85
votes
3answers
13k views

Why should I avoid the For loop in Mathematica?

Some people advise against the use of For loops in Mathematica. Why? Should I heed this advice? What is wrong with For? What ...
76
votes
2answers
7k views

Is there a way to separate variables between multiple notebooks?

I often correct homework by checking the calculations in Mathematica. Sometimes you would like to have two solutions open at once. However often defined symbols such as ...
57
votes
5answers
6k views

Are there any cases when For[] loops are reasonable?

To my mind the only reason for the existence of For[] loops in Mathematica is to allow new users with some experience in procedural programming languages to write ...
52
votes
7answers
75k 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? ...
52
votes
2answers
22k views

Can we use letter with a subscript as a variable in Mathematica?

I tried Subscript[a, 0] = 1 (* 1 *) Clear[Subscript[a, 0]] ...
44
votes
10answers
7k views

Programming paradigm change

I'm new to Mathematica, I've been learning by myself, and, being a Java developer for some time, it makes it hard to adapt. I've tried to solve a Reddit challenge, and I came up with this solution: <...
38
votes
4answers
9k views

Sort lists according to the order of another

I have three parallel lists (i.e. the elements in position i of each list are related). I want to sort the first list using the function Sort and make the same ...
38
votes
4answers
6k views

Debugging with Breakpoints

re: Version 9. I typically write concise code and make a real effort to refactor. As such debugging has tended to take care of itself. Recently, I've needed to assemble applications of more ...
35
votes
2answers
6k views

What is the difference between Set and SetDelayed?

I have a problem with defining a function and most of time I get confused by Set or = and ...
34
votes
4answers
9k views

How to modify function argument?

Usually in programming languages, function arguments are normal local variables, which can be modified. Is this not true in Mathematica? ...

15 30 50 per page
1
2 3 4 5
60