Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 142

General guidelines and best practices for Mathematica usage and programming.

33 votes

Changing Values in an Association using Map

I hesitate to add anything after @Leonid's comprehensive answer, but I'd like to point out that an easy way to achieve the stated goal is to define f like this: f[x_] := <| x, "isFirstValueTrue" -> x …
WReach's user avatar
  • 69.3k
22 votes

Resource management in Mathematica

There is an undocumented function, CheckAll, that can be used for this purpose. It dates back to at least version 7. All the usual caveats about undocumented functions apply -- it might not be suppo …
WReach's user avatar
  • 69.3k
5 votes

Resource management in Mathematica

Version 12.2 introduced WithCleanup, an experimental but documented function to ensure safe resource disposal. The example from the question would look like this when using WithCleanup: Module[{obj}, …
WReach's user avatar
  • 69.3k