Search Results
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 |
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.
2
votes
Accepted
What's wrong with SetDelayed? The body of the function works alone, while setdelayed to it a...
This is actually nontrivial: it has to do with how Mathematica manages scope after substituting in values that match a pattern (as in applying :=).
By inspecting poincare[sol, 1] // TracePrint, we see …
9
votes
Accepted
How to automatically interrupt `Set` with conditions
There's a standard trick for dealing with this problem! It involves setting up a so-called intercept, and is a general way to avoid using the same definition you're creating within the definition:
set …
7
votes
Accepted
Can substitution rules be used in function definitions?
It's not a problem with using rules in the def; it's a problem of whether x literally appears in the rhs or not.
When applying a definition where the pattern x_ on the lhs has been matched to an argum …
3
votes
Accepted
Automatically blend colours to a match
Get the palette in RGB:
RGBpalette = (List @@ ColorConvert[Hue[##], "RGB"]) & @@@ palette
Get the convex hull in RGB, and pick only those colors on the boundary—we'll use these for interpolation:
reg …
2
votes
0
answers
105
views
How does Mathematica choose which function definition to use?
I was wondering what the process of matching function arguments arguments against different function definitions actually looks like for Mathematica.
(Just to be clear, I'm not simply looking for an a …
0
votes
0
answers
51
views
Best way to simplify a polynomial before making it the body of a function?
So, I'm dealing with iterated polynomials of a single variable—say they're anonymous functions labeled as $p_i$, i.e. p[1], p[2], etc., and that these have explicit definitions. I'd like to compose a …
2
votes
Accepted
How to work symbolically with a compiled function?
EDIT: oooor, instead of following this answer, simply add the option RuntimeOptions -> {"EvaluateSymbolically" -> False}, as per @Michael E2's comment above :) (even though it's simple, I hope they'll …
0
votes
Restrict kinds of heads when dealing with level concept
Here's a way of checking the heads "on the way down", and only mapping through expressions with head head; I tried to account for Mathematica's usual level specification, but didn't manage to account …
4
votes
Accepted
Construct really identical function (the same as Length)
It's instructive to look at the output of TracePrint.
Length[Unevaluated[1 + 1 + 1 + 1]] // TracePrint
(* Out: *)
Length[Unevaluated[1+1+1+1]]
Length
Length[1+1+1+1]
4
Whereas
f[Unevaluated[1 …
11
votes
Help coding an Abelian Sandpile
The code below replaces pile with a function avalanche that works a bit bit differently! Instead of calling itself, it outputs a list of things that we then want to recursively call avalanche on again …
1
vote
generate quadratic functions to evaluate membership of points
Here's an answer; there could be some cleanup done, and I need to explain why some of the auxiliary functions work. But here you go—I tried to explain how it works in inline comments along the way, so …