Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.6K Views
|
4 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Default values for arguments of functions

POSTED BY: Vladimir Ivanov
4 Replies

Hans Milton, thank you for your example, it works.

Eric Rimbey, I use Mathematica 9. Concerning you opinion on default values, I have to think it over.

POSTED BY: Vladimir Ivanov
Posted 3 years ago
POSTED BY: Eric Rimbey
Posted 3 years ago

An example:

In[1]:= f[a_ : 50, b_ : 60, OptionsPattern[{c -> 70}]] := {a, b, OptionValue[c]}

In[2]:= f[10, 20]
Out[2]= {10, 20, 70}

In[3]:= f[10]
Out[3]= {10, 60, 70}

In[4]:= f[]
Out[4]= {50, 60, 70}

In[5]:= f[10, 20, c -> 3]
Out[5]= {10, 20, 3}
POSTED BY: Hans Milton
Posted 3 years ago
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard