Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    $\begingroup$ You assumed that, for each value of x, fwrap1 is called, then fwrap2. However, from the behavior you observe I suspect that Plot calculates all values for fwrap1 first, repeatedly rewriting the value of tmp and discarding the intermediate values you wanted to save; only afterwards does it move on to fwrap2. This would seem to make sense with the fact that only the value of tmp corresponding to one of the boundaries of the $x$ range is retained. $\endgroup$ Commented Oct 20, 2015 at 17:33
  • $\begingroup$ Thanks, that makes sense. I now tested the call order, and indeed, after an initial single call to each, there follows a row of calls only to fwrap1, and then another row of calls only to fwrap2. If you turn your comment into an answer, I'll accept it. $\endgroup$ Commented Oct 20, 2015 at 17:55
  • $\begingroup$ Glad it helped. I've converted to an answer below. $\endgroup$ Commented Oct 20, 2015 at 18:24