The differences amongst f[x_], f[x__], and f[x___]What are the use cases for different scoping constructs?Open and search Documentation-CenterWhat is the difference between Reduce and Solve?Functions that remember their valuesWays to access lists inside listsWhy is the Spherical Bessel Function acting strangely at this point?What is the relationship between Thread and MapThreadBad performance of Integrate (and WolframAlpha) for an Integral of Bessel function of the first kind: Version 11 edit
IEEE 754 square root with Newton-Raphson
How big would the ice ball have to be to deliver all the water at once?
How do my husband and I get over our fear of having another difficult baby?
Knights and Knaves: What does C say?
Can I pay some of the cost of an activated ability lots of times to get more out of the effect?
How does Monks' Improved Unarmored Movement work out of combat?
How to add the real hostname in the beginning of Linux cli command
A word that refers to saying something in an attempt to anger or embarrass someone into doing something that they don’t want to do?
Is it good to engage in exceptional cases where it is permissible to do a typically forbidden action to which one has a taivah for
How to compare integers in TeX?
As a team leader is it appropriate to bring in fundraiser candy?
Was the ruling that prorogation was unlawful only possible because of the creation of a separate supreme court?
Why does it seem the best way to make a living is to invest in real estate?
Windows 10 deletes lots of tiny files super slowly. Anything that can be done to speed it up?
Phonetic distortion when words are borrowed among languages
Why isn't there armor to protect from spells in the Potterverse?
Delete n lines skip 1 line script
Fix Ethernet 10/100 PoE cable with 7 out of 8 wires alive
Beyond Futuristic Technology for an Alien Warship?
How to bring home documents from work?
The differences amongst f[x_], f[x__], and f[x___]
Did Tolkien ever write about a Heaven or Hell for Men?
Creating specific options in `Manipulate[]`
Writing a program that will filter the integer solutions
The differences amongst f[x_], f[x__], and f[x___]
What are the use cases for different scoping constructs?Open and search Documentation-CenterWhat is the difference between Reduce and Solve?Functions that remember their valuesWays to access lists inside listsWhy is the Spherical Bessel Function acting strangely at this point?What is the relationship between Thread and MapThreadBad performance of Integrate (and WolframAlpha) for an Integral of Bessel function of the first kind: Version 11 edit
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
This is probably very elementary but I have not used the following and I cannot find anything online, and I was unable to find something here.
Can someone explain to me the differences amongst
f[x_]:=, f[x__]:=, f[x___]:=
and maybe give some practical examples so I can see the differences?
functions special-functions documentation
$endgroup$
add a comment
|
$begingroup$
This is probably very elementary but I have not used the following and I cannot find anything online, and I was unable to find something here.
Can someone explain to me the differences amongst
f[x_]:=, f[x__]:=, f[x___]:=
and maybe give some practical examples so I can see the differences?
functions special-functions documentation
$endgroup$
4
$begingroup$
Considerg1[x_]:= x
,g2[x__]:= x
, andg3[x___]:=x
and compareg1[]
,g1[5]
andg1[5,6]
(similarly forg2
andg3
).
$endgroup$
– kglr
8 hours ago
$begingroup$
Thank you for the comment. Some more questions. When I tried g3[5, 6, 7] it gave me 5,6,7 which is what I expected from the general pattern. However, g2[5, 6, 7] also gives the same result, so I am not sure what's the difference. Also g1[], g2[], just give back the same while g3[] gives back . Could you explain a bit more thoroughly? Am I missing something?
$endgroup$
– Konstantinos
7 hours ago
3
$begingroup$
Konstantinos, seeBlank (_)
,BlankSequence (__)
andBlankNullSequence (___)
in the docs for more details.g1
requires a single argument; sog1[]
andg1[2,3]
both return unevaluated.g2
requires 1 or more arguments sog2[]
returnsg2[]
; and ...
$endgroup$
– kglr
7 hours ago
1
$begingroup$
...g3
expects 0 or more arguments sog3[]
evaluates to,
g3[1,2,3]
gives1,2,3
andg3[1,2,3]
(one argument which is the list1,2,3
) gives1,2,3
etc.
$endgroup$
– kglr
7 hours ago
$begingroup$
Thanks a lot once more. I did not know how to find these online. I was trying something like f[__] Mathematica and nothing was popping up.
$endgroup$
– Konstantinos
7 hours ago
add a comment
|
$begingroup$
This is probably very elementary but I have not used the following and I cannot find anything online, and I was unable to find something here.
Can someone explain to me the differences amongst
f[x_]:=, f[x__]:=, f[x___]:=
and maybe give some practical examples so I can see the differences?
functions special-functions documentation
$endgroup$
This is probably very elementary but I have not used the following and I cannot find anything online, and I was unable to find something here.
Can someone explain to me the differences amongst
f[x_]:=, f[x__]:=, f[x___]:=
and maybe give some practical examples so I can see the differences?
functions special-functions documentation
functions special-functions documentation
asked 8 hours ago
KonstantinosKonstantinos
8631 gold badge5 silver badges14 bronze badges
8631 gold badge5 silver badges14 bronze badges
4
$begingroup$
Considerg1[x_]:= x
,g2[x__]:= x
, andg3[x___]:=x
and compareg1[]
,g1[5]
andg1[5,6]
(similarly forg2
andg3
).
$endgroup$
– kglr
8 hours ago
$begingroup$
Thank you for the comment. Some more questions. When I tried g3[5, 6, 7] it gave me 5,6,7 which is what I expected from the general pattern. However, g2[5, 6, 7] also gives the same result, so I am not sure what's the difference. Also g1[], g2[], just give back the same while g3[] gives back . Could you explain a bit more thoroughly? Am I missing something?
$endgroup$
– Konstantinos
7 hours ago
3
$begingroup$
Konstantinos, seeBlank (_)
,BlankSequence (__)
andBlankNullSequence (___)
in the docs for more details.g1
requires a single argument; sog1[]
andg1[2,3]
both return unevaluated.g2
requires 1 or more arguments sog2[]
returnsg2[]
; and ...
$endgroup$
– kglr
7 hours ago
1
$begingroup$
...g3
expects 0 or more arguments sog3[]
evaluates to,
g3[1,2,3]
gives1,2,3
andg3[1,2,3]
(one argument which is the list1,2,3
) gives1,2,3
etc.
$endgroup$
– kglr
7 hours ago
$begingroup$
Thanks a lot once more. I did not know how to find these online. I was trying something like f[__] Mathematica and nothing was popping up.
$endgroup$
– Konstantinos
7 hours ago
add a comment
|
4
$begingroup$
Considerg1[x_]:= x
,g2[x__]:= x
, andg3[x___]:=x
and compareg1[]
,g1[5]
andg1[5,6]
(similarly forg2
andg3
).
$endgroup$
– kglr
8 hours ago
$begingroup$
Thank you for the comment. Some more questions. When I tried g3[5, 6, 7] it gave me 5,6,7 which is what I expected from the general pattern. However, g2[5, 6, 7] also gives the same result, so I am not sure what's the difference. Also g1[], g2[], just give back the same while g3[] gives back . Could you explain a bit more thoroughly? Am I missing something?
$endgroup$
– Konstantinos
7 hours ago
3
$begingroup$
Konstantinos, seeBlank (_)
,BlankSequence (__)
andBlankNullSequence (___)
in the docs for more details.g1
requires a single argument; sog1[]
andg1[2,3]
both return unevaluated.g2
requires 1 or more arguments sog2[]
returnsg2[]
; and ...
$endgroup$
– kglr
7 hours ago
1
$begingroup$
...g3
expects 0 or more arguments sog3[]
evaluates to,
g3[1,2,3]
gives1,2,3
andg3[1,2,3]
(one argument which is the list1,2,3
) gives1,2,3
etc.
$endgroup$
– kglr
7 hours ago
$begingroup$
Thanks a lot once more. I did not know how to find these online. I was trying something like f[__] Mathematica and nothing was popping up.
$endgroup$
– Konstantinos
7 hours ago
4
4
$begingroup$
Consider
g1[x_]:= x
, g2[x__]:= x
, and g3[x___]:=x
and compare g1[]
, g1[5]
and g1[5,6]
(similarly for g2
and g3
).$endgroup$
– kglr
8 hours ago
$begingroup$
Consider
g1[x_]:= x
, g2[x__]:= x
, and g3[x___]:=x
and compare g1[]
, g1[5]
and g1[5,6]
(similarly for g2
and g3
).$endgroup$
– kglr
8 hours ago
$begingroup$
Thank you for the comment. Some more questions. When I tried g3[5, 6, 7] it gave me 5,6,7 which is what I expected from the general pattern. However, g2[5, 6, 7] also gives the same result, so I am not sure what's the difference. Also g1[], g2[], just give back the same while g3[] gives back . Could you explain a bit more thoroughly? Am I missing something?
$endgroup$
– Konstantinos
7 hours ago
$begingroup$
Thank you for the comment. Some more questions. When I tried g3[5, 6, 7] it gave me 5,6,7 which is what I expected from the general pattern. However, g2[5, 6, 7] also gives the same result, so I am not sure what's the difference. Also g1[], g2[], just give back the same while g3[] gives back . Could you explain a bit more thoroughly? Am I missing something?
$endgroup$
– Konstantinos
7 hours ago
3
3
$begingroup$
Konstantinos, see
Blank (_)
, BlankSequence (__)
and BlankNullSequence (___)
in the docs for more details. g1
requires a single argument; so g1[]
and g1[2,3]
both return unevaluated. g2
requires 1 or more arguments so g2[]
returns g2[]
; and ...$endgroup$
– kglr
7 hours ago
$begingroup$
Konstantinos, see
Blank (_)
, BlankSequence (__)
and BlankNullSequence (___)
in the docs for more details. g1
requires a single argument; so g1[]
and g1[2,3]
both return unevaluated. g2
requires 1 or more arguments so g2[]
returns g2[]
; and ...$endgroup$
– kglr
7 hours ago
1
1
$begingroup$
...
g3
expects 0 or more arguments so g3[]
evaluates to
, g3[1,2,3]
gives 1,2,3
and g3[1,2,3]
(one argument which is the list 1,2,3
) gives 1,2,3
etc.$endgroup$
– kglr
7 hours ago
$begingroup$
...
g3
expects 0 or more arguments so g3[]
evaluates to
, g3[1,2,3]
gives 1,2,3
and g3[1,2,3]
(one argument which is the list 1,2,3
) gives 1,2,3
etc.$endgroup$
– kglr
7 hours ago
$begingroup$
Thanks a lot once more. I did not know how to find these online. I was trying something like f[__] Mathematica and nothing was popping up.
$endgroup$
– Konstantinos
7 hours ago
$begingroup$
Thanks a lot once more. I did not know how to find these online. I was trying something like f[__] Mathematica and nothing was popping up.
$endgroup$
– Konstantinos
7 hours ago
add a comment
|
1 Answer
1
active
oldest
votes
$begingroup$
_
matches one thing.
__
matches one or more things.
___
matches zero or more things.
$endgroup$
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206799%2fthe-differences-amongst-fx-fx-and-fx%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
_
matches one thing.
__
matches one or more things.
___
matches zero or more things.
$endgroup$
add a comment
|
$begingroup$
_
matches one thing.
__
matches one or more things.
___
matches zero or more things.
$endgroup$
add a comment
|
$begingroup$
_
matches one thing.
__
matches one or more things.
___
matches zero or more things.
$endgroup$
_
matches one thing.
__
matches one or more things.
___
matches zero or more things.
answered 7 hours ago
John DotyJohn Doty
8,9361 gold badge14 silver badges27 bronze badges
8,9361 gold badge14 silver badges27 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206799%2fthe-differences-amongst-fx-fx-and-fx%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
$begingroup$
Consider
g1[x_]:= x
,g2[x__]:= x
, andg3[x___]:=x
and compareg1[]
,g1[5]
andg1[5,6]
(similarly forg2
andg3
).$endgroup$
– kglr
8 hours ago
$begingroup$
Thank you for the comment. Some more questions. When I tried g3[5, 6, 7] it gave me 5,6,7 which is what I expected from the general pattern. However, g2[5, 6, 7] also gives the same result, so I am not sure what's the difference. Also g1[], g2[], just give back the same while g3[] gives back . Could you explain a bit more thoroughly? Am I missing something?
$endgroup$
– Konstantinos
7 hours ago
3
$begingroup$
Konstantinos, see
Blank (_)
,BlankSequence (__)
andBlankNullSequence (___)
in the docs for more details.g1
requires a single argument; sog1[]
andg1[2,3]
both return unevaluated.g2
requires 1 or more arguments sog2[]
returnsg2[]
; and ...$endgroup$
– kglr
7 hours ago
1
$begingroup$
...
g3
expects 0 or more arguments sog3[]
evaluates to,
g3[1,2,3]
gives1,2,3
andg3[1,2,3]
(one argument which is the list1,2,3
) gives1,2,3
etc.$endgroup$
– kglr
7 hours ago
$begingroup$
Thanks a lot once more. I did not know how to find these online. I was trying something like f[__] Mathematica and nothing was popping up.
$endgroup$
– Konstantinos
7 hours ago