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
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
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 user 280

For questions on writing functions (pure or using Set/SetDelayed) for any purpose, including the features that may be incorporated in those functions, such as options, patterns and conditions.

1
vote
One workaround is to define g as: g[aa_] := Block[{a = aa}, NIntegrate[f[x], {x, 0, 1}]] This works because f[x] now is evaluated in local environment where variable a has a value. The reason why …
answered Feb 25 '14 by Alexey Popkov
4
votes
In addition to Kuba's answer: f4[x_] := Block[{val = (x^3 + 10 x - 5)}, val /; val >= 0] f4 will return unevaluated if the condition is not fulfilled. If it is desirable to get some value returned …
answered Apr 4 '14 by Alexey Popkov
11
votes
If you need to preserve the definitions of a Symbol with exception(s) to some particular case(s) you should use Internal`InheritedBlock: f[a_, b_] := a + b; Internal`InheritedBlock[{f}, f[1, 2] := a …
answered Nov 2 '14 by Alexey Popkov
3
votes
Just for completeness, here is another way: var = 2; DownValues[f] = HoldPattern[f[a_ : var]] :> {a}; Now f[] {2} and var = 5; f[] {5}
answered Aug 19 '16 by Alexey Popkov
8
votes
Here is how I would approach this: Clear[myEcho, myEchoCounter] myEcho::stop = "Further output from `` will be suppressed during evaluation of In[``]."; myEcho[, ] := myEcho[]; myEcho[label_: Null, m …
answered Mar 23 '17 by Alexey Popkov
12
votes
The problem arises when function returns a number smaller than $MinMachineNumber: function[t_] := Exp[-9 t^2]; LogLogPlot[function[t], {t, 8.8718, 8.872}, PlotRange -> All, GridLines -> {{{Sqrt[Log …
answered Nov 25 '13 by Alexey Popkov
6
votes
Your issue is quite simple and fundamental: you try to use lexical scoping (SetDelayed and Function) as it would be dynamic scoping (Block). So your problem can be solved easily by outsourcing the dyn …
answered Aug 22 '16 by Alexey Popkov
10
votes
The answer to the question depends upon what exactly should be called as "graphics primitive". In this answer from the practical point of view I define it as a container which can be found inside of G …
answered Jul 18 '15 by Alexey Popkov
6
votes
First of all, consider the following two successive inputs: Remove[f]; f[x_] := 1; {f, Head[f], SymbolName[f], AtomQ[f], DownValues[f]} {f, Head[f], SymbolName[f], AtomQ[f], DownValues[f]} {Remov …
answered Oct 22 '16 by Alexey Popkov