Linked Questions

2
votes
1answer
82 views

How to form list of all OwnValues of symbols in Global context? [duplicate]

How do I get the list of all OwnValues of symbols in the Global` context? All my attempts have failed because ...
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 ...
67
votes
10answers
3k views

Injecting a sequence of expressions into a held expression

Consider the following toy example: Hold[{1, 2, x}] /. x -> Sequence[3, 4] It will give Hold[{1, 2, Sequence[3, 4]}] ...
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? ...
14
votes
3answers
7k views

Assigning values to a list of variable names

As part of a calculation I need to do something like this Evaluate[{aaa, bbb, ccc}[[ index]]] = {1, 2, 3, 4, 5} so if index is ...
16
votes
3answers
2k views

How to implement a regular grammar?

What is the most simple, elegant way of implementing a rewrite-system defined as: $$ \begin{aligned} \Sigma &= \{a_1, a_2, a_3, ...\} \\ N &= \{A_1, A_2, A_3, ...\} \\ \{\alpha_1 , \...
13
votes
4answers
2k views

Passing large list by reference

I have the following problem: I would like to control evaluation of a variable that points to a list. For example, frequently in the code I have functions of the form that are supposed to work on ...
17
votes
1answer
2k views

Get the name of a symbol passed to a function

I'm trying to get the name of a symbol passed to a function with this: f[x_] := {SymbolName[x], x} SetAttributes[f, HoldFirst] x = 5; f[x] But ...
8
votes
1answer
2k 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. ...
1
vote
1answer
383 views

Unevaluated symbols [duplicate]

I often find it useful to define a symbol from strings (often in a loop in which I define other symbols). This I accomplish with Symbol (and often ...
1
vote
1answer
416 views

Passing a joined list of symbols for Module or Block to treat as its own local symbols

The Question I'd like to write a function which itself takes a list of symbols, e.g. Foo[{x, y, z}] to pass to Module within,...
3
votes
1answer
286 views

Generate assignment code to symbols from string

I want the function to take in string, then assign a value to its corresponding symbol. An implementation using ToExpression is ...
0
votes
1answer
134 views

How to apply Set to held symbols listed in a variable?

I have a variable states that contains a list of held symbols: ...
1
vote
1answer
122 views

Making two lists which share part of its name, while its name is also an element of the list

I am stalled with the following problem: I want two lists, for example: name={1,2,3} and namec={{1,2,3},{x,y,z},name} The ...

15 30 50 per page