Function[u, g[u]] vs. Function[u, g[u]] : In which the behavior between differs?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Function[u, g[u]]
Function[u, g[u]]
The documentation lists both variants without specifying the difference.
Does the behavior differ in some circumstances?
function-construction documentation
add a comment |Â
up vote
2
down vote
favorite
Function[u, g[u]]
Function[u, g[u]]
The documentation lists both variants without specifying the difference.
Does the behavior differ in some circumstances?
function-construction documentation
1
No difference, just some flexibility in the syntax for single-variable functions
– Michael E2
25 mins ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Function[u, g[u]]
Function[u, g[u]]
The documentation lists both variants without specifying the difference.
Does the behavior differ in some circumstances?
function-construction documentation
Function[u, g[u]]
Function[u, g[u]]
The documentation lists both variants without specifying the difference.
Does the behavior differ in some circumstances?
function-construction documentation
function-construction documentation
asked 44 mins ago


Slepecky Mamut
31818
31818
1
No difference, just some flexibility in the syntax for single-variable functions
– Michael E2
25 mins ago
add a comment |Â
1
No difference, just some flexibility in the syntax for single-variable functions
– Michael E2
25 mins ago
1
1
No difference, just some flexibility in the syntax for single-variable functions
– Michael E2
25 mins ago
No difference, just some flexibility in the syntax for single-variable functions
– Michael E2
25 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
There is no functional difference between Function[u, g[u]]
andFunction[u, g[u]]
. The following difference in speed is small but consistent on my machine (MacBook Pro):
foo = Range[5*10^6];
foo[[1]] = 1.;
Function[x, x] /@ foo; // RepeatedTiming
Function[x, x] /@ foo; // RepeatedTiming
(*
2.4, Null
2.0, Null
*)
It's a small difference compared to the execution time of more complicated function bodies.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
There is no functional difference between Function[u, g[u]]
andFunction[u, g[u]]
. The following difference in speed is small but consistent on my machine (MacBook Pro):
foo = Range[5*10^6];
foo[[1]] = 1.;
Function[x, x] /@ foo; // RepeatedTiming
Function[x, x] /@ foo; // RepeatedTiming
(*
2.4, Null
2.0, Null
*)
It's a small difference compared to the execution time of more complicated function bodies.
add a comment |Â
up vote
3
down vote
There is no functional difference between Function[u, g[u]]
andFunction[u, g[u]]
. The following difference in speed is small but consistent on my machine (MacBook Pro):
foo = Range[5*10^6];
foo[[1]] = 1.;
Function[x, x] /@ foo; // RepeatedTiming
Function[x, x] /@ foo; // RepeatedTiming
(*
2.4, Null
2.0, Null
*)
It's a small difference compared to the execution time of more complicated function bodies.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
There is no functional difference between Function[u, g[u]]
andFunction[u, g[u]]
. The following difference in speed is small but consistent on my machine (MacBook Pro):
foo = Range[5*10^6];
foo[[1]] = 1.;
Function[x, x] /@ foo; // RepeatedTiming
Function[x, x] /@ foo; // RepeatedTiming
(*
2.4, Null
2.0, Null
*)
It's a small difference compared to the execution time of more complicated function bodies.
There is no functional difference between Function[u, g[u]]
andFunction[u, g[u]]
. The following difference in speed is small but consistent on my machine (MacBook Pro):
foo = Range[5*10^6];
foo[[1]] = 1.;
Function[x, x] /@ foo; // RepeatedTiming
Function[x, x] /@ foo; // RepeatedTiming
(*
2.4, Null
2.0, Null
*)
It's a small difference compared to the execution time of more complicated function bodies.
answered 14 mins ago
Michael E2
142k11192458
142k11192458
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184384%2ffunctionu-gu-vs-functionu-gu-in-which-the-behavior-between-differ%23new-answer', 'question_page');
);
Post as a guest
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
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
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
1
No difference, just some flexibility in the syntax for single-variable functions
– Michael E2
25 mins ago