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 12

Questions about the use of built-in Mathematica functions, including pure functions.

5
votes
Two possible ways: listfun = {Sin, Cos, Tan}; Through[listfun[Pi]] (* {0, -1, 0} *) #[Pi] & /@ listfun (* {0, -1, 0} *)
answered Jul 8 '16 by Szabolcs
1
vote
The usual term is connected components. You can use Length@WeaklyConnectedComponents[graph]. This will work on directed graphs as well, assuming that you are looking for the components of the underl …
answered Feb 19 by Szabolcs
7
votes
Like in all other systems I am familiar with, variable and function definitions exist in memory (RAM) only and do not persist across sessions. If you want a definition to persist, you must save it ex …
answered Mar 15 by Szabolcs
12
votes
As others mentioned, there's the ND function from the NumericalCalculus` package. It's a bit less widely known that Derivative is also able to approximate derivatives purely numerically. Let's creat …
answered Nov 12 '12 by Szabolcs
13
votes
While While[procedure; test] works, it looks very similar to While[test, procedure]. The only difference is ; vs ,. While is not the most commonly used construct, so when used like this there's a hi …
answered Mar 18 '14 by Szabolcs
39
votes
[RandomInteger[10000, 300]]] Implementing functions that localize their arguments Functions like Table, Sum, Plot, FindRoot, NIntegrate, etc. use Block to localize their variable. Here's a possible … useful for modifying existing (or built-in) functions temporarily. Here's an example to illustrate: Print does not have the HoldAll attribute: Print[1 + 1] (* ==> 2 *) We can assign HoldAll to Print …
answered Jan 23 '12 by Szabolcs
8
votes
several locations or when passed to functions. For more information see Share. Number (2) is what you are asking about in your question. To enable a function to modify its argument in Mathematica, it …
answered Feb 14 '14 by Szabolcs
22
votes
in practice. It only makes sense to use this if you have some sort of requirement to only use documented functions. If you do this, do not forget to also provide a nice OutputForm, which will be …
answered Nov 19 '15 by Szabolcs
1
vote
Because the latter is equivalent to {1,2,3,4,5}[[2]] = 0 which is invalid. The former stays as listCopy[[2]] = 0 You can't change (i.e. assign to) parts of a literal like this. You can chang …
answered Aug 5 '14 by Szabolcs
2
votes
You need to use Set instead of SetDelayed. Please see here for an explanation of the difference: What is the difference between Set and SetDelayed? First make sure that x has no value assigned. The …
answered Jan 9 '14 by Szabolcs
12
votes
The simplest solution is to rescale the data. Suppose we have a distance limit of $r_x = 2$ and $r_y = 1$ and a point set data = {{x1,y1}, {x2,y2}, ...} Instead of working with data and these two …
answered Feb 25 '14 by Szabolcs
3
votes
The problem is that the definition of CirclePlus is not distributed to parallel kernels. You can test this using DistributeDefinitions[CirclePlus] (* {} *) ParallelEvaluate[Print@Definition[CircleP …
answered Sep 6 '17 by Szabolcs
4
votes
I can see why this is confusing. Plotting functions try to be too smart, and hide the true way in which they handle their colour functions. Plotting functions typically pass multiple values to their … -> myRainbow[#3])& and will result in an error. The typical way to work with colour functions is to define a function which converts a single number (single argument) to a colour, then build a pure …
answered Nov 24 '17 by Szabolcs
5
votes
If test is a list of numbers, your code works fine: f[x_] := (If[x > 0, x*n1, 0]) test = {1, 2, 3, -1}; f /@ test (* {n1, 2 n1, 3 n1, 0} *) If you import test from an Excel file, Mathematica migh …
answered Jan 15 '16 by Szabolcs
2
votes
Use Apply. The following will work: func @@@ list Example: In[1]:= f @@ {1, 2, 3} Out[1]= f[1, 2, 3] In[2]:= f @@@ {{1, 2, 3}, {4, 5, 6}} Out[2]= {f[1, 2, 3], f[4, 5, 6]}
answered Mar 18 '15 by Szabolcs

15 30 50 per page