# Tagged Questions

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

325 views

### Return partial result when MemoryConstrained aborts NDSolve

I use NDSolve to solve a large set (~400) of coupled ODEs. Sometimes, the memory (~4GB) gets filled up, and my computer becomes impossible to work with, because it ...
1k views

### Every second evaluation in notebook front end is slow

I'm having a rather baffling problem that Wolfram was unable to help me diagnose, and I'm hoping one of you geniuses in residence here can figure it out. (I don't get access to the Technical Support ...
454 views

### Order of evaluation - does Mathematica evaluate variables before or after substitution?

Let's say I write y = x^2; x = 10; z = y + y^2 + y^3 Does Mathematica internally evaluate y before or after substituting it into z? I.e., does Mathematica ...
268 views

### The introduction for Context in Wagner's book is out of date? [duplicate]

In Section 8.1.1 (P230 of the book, P249 of the PDF) of Wagner's book, the following example is shown: x = 5; tempx = 6; Begin["temp"]; {x, Global`x} The ...
242 views

### Leave expression tree formatting the same when a replacement rule is applied

If I type e1 := 3 x + 2 (1 + y) z // TreeForm, I get an expression tree. If I then type e1 /. x -> 3, I get another ...
338 views

### How to take and evaluate a specific part of a list without evaluating the rest?

I have a large list, for example, lis = {x + y, x y, Sin[x] y + Exp[y], x^2 y} and its elements depend on variables x and <...
3k views

### Keyboard shortcut to evaluate notebook

(If this is entirely trivial, although I couldn't find an answer as much as I searched the archives, I will delete the question.) How could I add a keyboard shortcut to evaluate the entire notebook ...
353 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 2....
344 views

### Why does the documentation call functions “pure”?

Clearly, functions in mathematica are not pure functions according to the definition on Wikipedia (no side effects - basically implementabe with table lookups): ...
191 views

### Subtle difference in conditional rules placement

I had gotten used to thinking of the placement of a condition in a rule definition as logically immaterial. In my specific example, namely ...
337 views

### Unexpected differences with various uses of NormFunction

I would expect all of the following to give the same answer (2.12467) but only half of them give this answer. The others seem to be using the default ...
108 views

### Evaluation leak from Dynamic in Button's action

a = 1; Button["Print", a++] Button["Print", Dynamic[a++]] Button["Print", Dynamic[a++];] Button["Print", {Dynamic[a++]}] Dynamic @ a The second ...
387 views

### Nothing not behaving as expected?

I was thinking that Nothing was doing the same job as the vanishing sequence ##&[]. Yet this exemple shows it doesn't. ...
457 views

### A problem about the implementation of Bezier curve

I implemented the Bezier curve like built-in BezierCurve as follow: SplineDegree -> d specifies that the underlying ...
284 views

### Held keys in associations

Jacob Akkerboom commented: Note that PositionIndex does work correctly with held expressions, whereas this is a bit painful to implement using ...
124 views

### Aborting from inside a ScheduledTask

If you have an Abort[] inside a ScheduledTask expression, what does it abort? The scheduled task evaluation, or any main kernel ...
475 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 ...
122 views

### Use EvaluationCompletionAction to notify me only after long evaluation

Is it possible to use the option EvaluationCompletionAction to notify me (e.g. with a Beep[]) when an evaluation that took ...
315 views

### Another difference between Set and Setdelayed. Evaluation shortcut?

A little while ago I wondered why f[x_] = f[x] gives an infinite iteration. I ended up discovering the following difference in evaluation between ...
368 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 ...
318 views

### How to exit from the innermost enclosing pure function?

Here is what I tried to do: Scan[Function[x, Scan[Function[y, If[y == 2, Return[]]; (* Do something useful *) Print[y]], x]], {{1, 2, 3}, {4, 5, 6}}] ...
323 views

### How to see which arguments are passed into a function

It is often that one wonders which arguments are evaluated before being passed into a function. I would like to know if it is possible to see which argumets are being passed into a function without ...
474 views

### Why do I have to put Evaluate[] here

I wanted to draw some contours. I succeeded with this: ...
352 views

### Using up-values and down-values

I have a problem I'm trying hard to find a solution for, although I don't know if a solution exists. The following rules produce the result e[2].f[] ...
778 views

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

I am doing a little project to demonstrate something: ...
107 views

### Different behaviour of ValueQ inside and outside of a loop

I need to store a rather big number of variables and I tried to do that by storing each variable as Z[n] with varying n. I guess this was not my best idea. The first problem I encountered is when I ...
248 views

### Half-delayed evaluation

In a certain wider context, I need to make some delayed definitions, such as x := a + b + c, but within these definitions I want ...
425 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 <...
158 views

### Tracking Initialization

How to track Initialization step by step? Any tricky solution is ok. One condition, x should be ...
290 views

### Menu item “Interrupt Evaluation…” missing in V10

The menu item “Interrupt Evaluation…” seems to have disappeared in Mathematica 10 on OS X. Well, this is a bummer. I personally use Mathematica for very long calculations, and I was using this ...
181 views

### Implement settable properties

I am looking for advice on implementing the following. (It is possible that the answer is that it is simply not a good idea to do this.) I would like to have an object similar to ...
374 views

### Understanding Villegas-Gayley

Temporary message: I have written another question about the behaviour the code by Oleksandr R. . Sadly I clicked "discard" and that was lost. I am a bit demotivated now and in order to not let the ...
144 views

### Is it possible to use the global definition of a symbol as part of its new local definition set in a Block?

Consider the following expression: Block[{Print = CopyToClipboard}, doSomething[]] Now all calls to Print from ...
136 views

### Why does $Failed have attribute HoldAll? Why does$Failed have attribute HoldAll? Are there typical situations where $Failed is ... 2answers 184 views ### A notebook created on demand from a main document showing executable input along with output cells I would like to make Mathematica documents with hidden calculations, such that they can be visualized on demand. In general it can be done in several forms and I actually use some. I would like to ask ... 1answer 359 views ### Performance of Dispatch and lists of Rules The issue outlined here seems to be no longer present in version 10, if you use a Dispatch table! This because a Dispatch table ... 1answer 148 views ### Prevent Plus from threading InterpolatingFunction For an InterpolatingFunction$y:\ \mathbb{R}\to\mathbb{R}^2$, Plus is unaware of this, so when I do any modifications to it in ... 1answer 183 views ### Comparing exact expressions for equality — is it really OK if I get wrong answer? Bug introduced in 7.0 or earlier and fixed in 10.2.0 I found an unexpected behavior (that I think of as a bug) in evaluation of the equality operator applied to mathematical functions with exact ... 1answer 121 views ### How useful is$EvaluationEnvironment?

Bug introduced in 10.0 and persisting through 10.4.1 A support case with the identification [CASE:3618534] was created. [...] I filed a report with our development team raising the issues [.....
67 views

### Is there a way to TagSet a HoldAllComplete function?

Let's say I want to overload the built-in function Lookup, to handle my data wrapped in myObject. One would use ...
8k views

### Mapping multiple parameters of a function to specific values

I am a little bit confused by the documentation for Apply (@@). I want to define a list of parameters, for instance: ...
302 views

### How to inject unevaluated list of Unique into a RuleDelayed?

I am writing a function that constructs a rule which has Unique[] in the RHS. Here is a simplified segment of code ...
317 views

### Generate list of strings from a list of assigned variables

How do I generate a list of strings from a list of assigned variables? Eg. Convert ...
321 views

### Unexpected behavior of rule matching a pattern

I am a beginner exploring the world of Mathematica. I expected the following code T[6, 5, 4, 1, 2, 3] /. {T[a___, 1, b___] -> Length[List[b]]} should return ...
225 views

### Why does the name of a pattern affect the result of a transformation rule?

I was playing a little dirty, trying to get a template for defining a Curl[] operator. I wrote the following rule, which I knew was going to spit out a few ...
2k views

### Force function to make assumptions about its input variables in Mathematica

I'm trying to force a Mathematica function to make an assumption about its input variables. In my case, I'm trying to define a function to return the pdf of a Gaussian. But let's use a simple toy case:...
833 views

### Why are functions called first-class objects in Mathematica?

I've heard lots of people say a function is a first-class object in Mathematica. "Everything is an expression, including function." "There is no distinction between functions and data." Having read ...
240 views

### Graphics in Notebook Different from Graphics Expression?

Consider the expression TreeForm[a+b^2+c^3+d] which displays as This is a nice Graphics object, as I can prove by typing ...