Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.

learn more… | top users | synonyms

9
votes
2answers
629 views

How to make Mathematica re-evaluate a cell after some event?

I am doing a little project to demonstrate something: ...
9
votes
2answers
368 views

Defining a ForEach function

Consider the following function definition: ForEach[iterators__] := Table[#, iterators] &; Two questions about it: I. It works perfectly if you call it like ...
10
votes
3answers
344 views

Why does ++++x return an increment of 2 when the value of x is only incremented by 1?

This line returns 3: x = 1; ++++x However, the value of x after the increment is only ...
1
vote
0answers
112 views

is there an equivalent of “show” steps? [duplicate]

Possible Duplicate: Get a “step by step” evaluation in Mathematica In wolfram alpha, when preforming for complicated integrals there's a 'show steps' option that explains how ...
8
votes
3answers
332 views

How to write a function-defining function which stores the function arguments in a stack?

I have a function-defining function SetAttributes[DefFn, HoldAll]; DefFn[f_[args___], body_] := f[args] := body; I am trying to modify this function to record ...
2
votes
1answer
838 views

A combination of Set::setraw and Set::shape errors

Please consider the following toy code: ...
42
votes
8answers
2k 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]}] ...
8
votes
3answers
172 views

With/Function(/etc) replacement behaviour

Can anyone explain to me this behaviour? I've been having more than a couple of similar doubts these last weeks. For example f[_?NumericQ] := 8; Now, if I do ...
55
votes
4answers
4k views

Plot draws list of curves in same color when not using Evaluate

This example comes from the Mathematica documentation for Plot under Basic Examples. Can someone please explain why these are each plotted as a different color in ...
13
votes
3answers
526 views

Does AbsoluteTiming slow the evaluation time?

I've started using AbsoluteTiming to discriminate between similar function constructs, but I sometimes feel like it takes substantially more time to evaluate a ...
4
votes
2answers
202 views

Setting a lower limit on calculation time

Sometimes it can come in handy to set a lower limit for a calculation. Consider for example an animation that is generated by some infinite loop, which would run way too fast to display properly for ...
13
votes
5answers
1k views

How to determine how much of a table is generated?

If I'm generating a table from a slow function, like this: foo = Table[SuperSlowExpression, {1000}] is there a way to determine after submission (so it is too ...
20
votes
2answers
493 views

Implementing a safe ValueQ that does not evaluate its argument

Mathematica has a built-in function ValueQ. Quoting the docs, ValueQ[expr] gives True if ...
11
votes
3answers
5k views

General::ivar is not a valid variable when plotting - what actually causes this and how to avoid it?

I was just evaluating a couple of expressions and started to get errors like this: ...
10
votes
2answers
225 views

Bags and non-standard evaluation

What can internally be happening here? Is the evaluator just messing with us and going non-standard because it's a Bag? Or am I just not seeing how something like ...
20
votes
5answers
949 views

How do you programatically load data into symbols?

I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to ...
19
votes
4answers
431 views

Function that caches when it returns unevaluated

How would you go about implementing a function that caches not the result but the fact that it didn't match a pattern? So that it doesn't waste time recomputing a complex time-consuming pattern ...
26
votes
1answer
825 views

How do you set attributes on SubValues?

SubValues, as discussed in a previous question, are declared as follows ...
21
votes
2answers
497 views

Context unique to each group at a specified level

Are there any new tools in v10 that might be applicable to this problem? Recent versions of Mathematica provide the option of having a unique $Context for each ...
41
votes
4answers
2k views

How do I evaluate only one step of an expression?

I am looking for a simple, robust way to evaluate an expression only one step, and return the result in a held form. The definition of a single step is ambiguous, and this itself is probably worthy ...
20
votes
5answers
591 views

Reassign values to symbols

I've got a situation where I have, say 4 symbols, a, b, c and ...
6
votes
1answer
268 views

How to simplify expression and use HoldForm at the same time?

Hopefully a simple problem for the experts here. I have a need many times to build a symbolic expression for an equation (say a PDE) to use for plot labels in a low level function inside ...
18
votes
3answers
1k views

Asynchronous evaluation: Is it possible?

Currently we have a limited number of ways to perform asynchronous evaluation. The most common is through Dynamic and ...
14
votes
3answers
252 views

How can I test properties of a symbol from the string name without the symbol completely evaluating

Suppose I have a few symbols, one of which has a value: {abc1, abc2 = 5, abc3}; I can use Names to get the list of names, as ...
75
votes
5answers
48k views

Get a “step-by-step” evaluation in Mathematica

Is it possible in Mathematica to get a step-by-step evaluation of some functions; that's to say, outputting not only the result but all the stages that have led to it? If so, how does one do it? ...
10
votes
1answer
446 views

Manipulate evaluation sequence

Manipulate doesn't always evaluate in the order I expect it to. What is the evaluation sequence for Manipulate and other ...
22
votes
1answer
477 views

How does Return work?

It is not completely clear to me how Return[] works. The documentation says: Return[expr] returns the value expr from a ...
44
votes
3answers
1k views

The clearest way to represent Mathematica's evaluation sequence

WReach has presented here a nice way to represent the Mathematica's evaluation sequence using OpenerView. It is much more clear way to go than using the standard ...
8
votes
2answers
663 views

How does Mathematica determine that an evaluation should be terminated?

How exactly does Mathematica determine that evaluation of particular expression should be finished and the result should be returned? Here are some examples of unclear behavior which have arisen, ...