In:= ReleaseHoldAt], level spec, Replace will try to match-and-replace the rule against these two expressions, and it will work on the second one. This lets us illustrate another reason why it might not make sense for Evaluate to work at any level in an expression passed as an argument to a function with a Hold* attribute, considering the following expression involving i: In:= i = 1 I can't give the exact reason why Evaluate "works only on the first level, directly inside a held function" but I suspect it's partly efficiency, in that it would be slow if the evaluator had to scan the complete expression tree of held arguments passed to any function with a Hold* attribute for nested Evaluate expressions and evaluate them, and then recurse and look for Evaluate subexpressions in what it just evaluated, all while keeping the rest of the expression unevaluated, especially when this might not always be what you want to happen anyway.ĭoing what you want is pretty easy using a combination of Extract and ReplacePart though: In:= expr = Hold, 2]] There is no parallel for in Mathematica, but there is a ParallelDo and more importantly a ParallelTable. Naively I would think Mathematica recognizes unsolvable problems, or problems that would take an irreasonable time to solve and at least warn the user. You find that Mathematica will evaluate lower levels in the background when you really want it to wait. Actually Mathematica didnt spit out a solution for about twenty minutes now, but interestingly it wont say its unsolvable, or anything. If you release the first hold and place a hold on a higher level in a expression at the third Plus, to look like this: in = Plus]], 2]]] A Crash Course in Mathematica, Stephan Kaufman, 1999, 200 pages, for Mathematica version 3, ISBN 3764361271, Library-of-Congress QA 76.95 K3913 1999 Steenbock Library. Are there any other approaches or functions for achieving this I could consider?Įdit: This might be a better example to look at the approach of releasing the first hold.
0 Comments
Leave a Reply. |