Linked Questions

10
votes
1answer
1k views

Should I add a semicolon after a function definition? [duplicate]

should I write the program like this: f[x_]:=x^2; g[x_]:=x+2; or should I write the program like this: ...
1
vote
1answer
883 views

How to make an empty list inside a module program? It consatly spews errors [duplicate]

Okay, so, I'm trying to write a program within the module. It goes like this: create empty list, join it with a sample from a certain set called MyList, and then repeat it certain number of times. ...
0
votes
1answer
110 views

Functions as objects [duplicate]

I have a very long program I'm trying to stuff express as a single function. (I'll include it at the bottom of my post.) My long-term goal is to trim out the file handling portion of this function, ...
0
votes
0answers
34 views

Next line without “;” and set::write error => why? [duplicate]

In my code I first wrote : Print["else"] beta156v345 = 1/Sin[theta15]*1/ Sin[theta35]*(Cos[theta13]*1 - Cos[theta15] Cos[theta35]); (* j1^j5 . j3^j5 *) ...
455
votes
37answers
101k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
25
votes
2answers
2k views

Using a list of tuples in a pure function

I want to use a list of tuples within a function to make assignments. Say I want to make assignments of the form value[i,j] = val What I have is a list of ...
13
votes
2answers
3k views

Why is this semicolon in red?

I have a piece of code that works well, but when I put a semicolon after a plotting statement, the semicolon appears in red. What's the error?
5
votes
1answer
7k views

Creating a multiline function with localized variables

I would like to create a function with several expressions in the code body. For example, I would like to write something like this, but which will actually work. ...
4
votes
1answer
303 views

Why do I get the Null when I evaluate Print[x] // InputForm? [duplicate]

When I execute: Print[x]//InputForm I get a Null at the last line of the result. This is an example shown in the ...
6
votes
1answer
258 views

Should I end all definitions from packages with semicolon?

I noticed that if I open a .m file in Mathematica and click on the Run Package button, all the ...