Linked Questions

10
votes
1answer
566 views

Modifying a List in a function in place [duplicate]

An example will be most specific: func[list_, column_] := list[[All, column]] = Map[#*2 &, list[[All, column]]]; This throws errors. I want to avoid doing ...
0
votes
1answer
73 views

Change input variable in a function [duplicate]

I'd like to write a function, that would take a matrix as an input parameter and would change it by multiplying one of its rows by a factor. I try to do it in the following way: ...
0
votes
1answer
76 views

Circumventing the default scoping: Assign a variable inside a function [duplicate]

I'm currently trying very hard to assign a variable inside a function. Therefore I'm using a function like this, which should reassign a predefined variable. ...
165
votes
19answers
17k 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 ...
19
votes
5answers
1k views

How to pass a symbol name to a function with any of the Hold attributes?

Given a function with the attribute HoldFirst, HoldAll or similar, and a variable, list, how ...
16
votes
2answers
336 views

When should I, and when should I not, set the HoldAll attribute on a function I define?

I have seen a number of examples on this site (such as in syntax highlighting and checking evaluation status) in which functions definitions are preceded with ...
13
votes
2answers
607 views

Question about designing a particular data structure

Background: I store polygons with a color assigned at the face level. In some occasions I want to use vertex colors but I want to store data efficiently, i.e. don't want to duplicate data to the ...
5
votes
1answer
426 views

Using the symbol I for electrical current [duplicate]

I would like to use the I as a symbol for the electrical current. How can I redefine it, so it is not interpreted as the imaginary unity?
2
votes
3answers
2k views

Passing a matrix as a function argument

I am trying to do the following: ...
11
votes
3answers
353 views

Pass by reference for an option argument

Pass by reference can be faked by using HoldAll or something similar in the definition of a "Function". But can pass by reference be faked for symbols passed as ...
4
votes
1answer
511 views

How do I treat elements in a list as variables inside a module?

I want to be able to assign values to a list element inside a module. For example if I have: ...
3
votes
1answer
395 views

Is there anything like a C pointer (or returning a reference) in $Mathematica$?

I want to do in Mathematica what the following does in C. ...
6
votes
1answer
177 views

Does pass-by-value affect the performance of function calls?

I only have a little coding experience in C, and I remember I was told that pass by reference is more efficient than pass by value since the parameters don't need to be copied. Since there is no pass ...
2
votes
2answers
101 views

15 30 50 per page