Function[u, g[u]] vs. Function[u, g[u]] : In which the behavior between differs?

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question

















  • 1




    No difference, just some flexibility in the syntax for single-variable functions
    – Michael E2
    25 mins ago














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?










share|improve this question

















  • 1




    No difference, just some flexibility in the syntax for single-variable functions
    – Michael E2
    25 mins ago












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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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












  • 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










1 Answer
1






active

oldest

votes

















up vote
3
down vote













There is no functional difference between Function[u, g[u]] and
Function[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.






share|improve this answer




















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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]] and
    Function[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.






    share|improve this answer
























      up vote
      3
      down vote













      There is no functional difference between Function[u, g[u]] and
      Function[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.






      share|improve this answer






















        up vote
        3
        down vote










        up vote
        3
        down vote









        There is no functional difference between Function[u, g[u]] and
        Function[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.






        share|improve this answer












        There is no functional difference between Function[u, g[u]] and
        Function[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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 14 mins ago









        Michael E2

        142k11192458




        142k11192458



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery