Tag for questions about using optional arguments in Mathematica functions.
13
votes
3answers
151 views
Can I make a default for an optional argument the value of another argument?
I'd like to define a function with several optional arguments, some of which default to the value supplied for other arguments. For example, I'd like to be able to write something like
...
11
votes
1answer
164 views
Is it possible to use Compile on a function with optional arguments?
My Mathematica is a little rusty, so apologies in advance. I think my problem is quite simple, but I can't seem to find the answer on my own!
Simple example : ...
10
votes
2answers
274 views
How to test if optional argument has been given?
I understand that the last call (f[1]) returns True because arg does not exist and thus ...
9
votes
1answer
339 views
How to Combine Pattern Constraints and Default Values for Function Arguments
EDIT: As several respondents have noted in the answers and comments below, the original example had a default value that would never be used because of the way patterns and default values are ...
6
votes
2answers
125 views
Is it possible to use PatternTest and Optional value on one Pattern simultaneously? [duplicate]
Possible Duplicate:
How to Combine Pattern Constraints and Default Values for Function Arguments
First a simple example: define a function "add" with two arguments, and its second argument ...
4
votes
2answers
148 views
How to use Optional as an omissible parameter in pattern-match?
Below is a function intended to test if an expression is a polynomial in which all the coefficients and exponents are integers:
...
2
votes
0answers
72 views
How can this function's options be used in different places?
I wrote this function to make a ListPlot where the points are colored by a third argument.
...