What does _. mean in patterns? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












Here is a quick one, hopefully. I searched through different tutorials and documentation articles but haven't been able to find anything yet.



What does _. mean? As in _,_. as opposed to _,_ or _,_,_. as opposed to _,_,_?



Thanks!










share|improve this question













closed as off-topic by xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba♦ Sep 14 at 6:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 3




    "I searched through different tutorials and documentation articles but haven't been able to find anything yet." Then you haven't yet learned the correct usage of document: i.stack.imgur.com/RVvvv.gif
    – xzczd
    Sep 13 at 17:28










  • @xzczd Thanks! I didn't actually know about that!
    – Jmeeks29ig
    Sep 13 at 17:30














up vote
6
down vote

favorite












Here is a quick one, hopefully. I searched through different tutorials and documentation articles but haven't been able to find anything yet.



What does _. mean? As in _,_. as opposed to _,_ or _,_,_. as opposed to _,_,_?



Thanks!










share|improve this question













closed as off-topic by xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba♦ Sep 14 at 6:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 3




    "I searched through different tutorials and documentation articles but haven't been able to find anything yet." Then you haven't yet learned the correct usage of document: i.stack.imgur.com/RVvvv.gif
    – xzczd
    Sep 13 at 17:28










  • @xzczd Thanks! I didn't actually know about that!
    – Jmeeks29ig
    Sep 13 at 17:30












up vote
6
down vote

favorite









up vote
6
down vote

favorite











Here is a quick one, hopefully. I searched through different tutorials and documentation articles but haven't been able to find anything yet.



What does _. mean? As in _,_. as opposed to _,_ or _,_,_. as opposed to _,_,_?



Thanks!










share|improve this question













Here is a quick one, hopefully. I searched through different tutorials and documentation articles but haven't been able to find anything yet.



What does _. mean? As in _,_. as opposed to _,_ or _,_,_. as opposed to _,_,_?



Thanks!







pattern-matching argument-patterns






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 13 at 16:56









Jmeeks29ig

56929




56929




closed as off-topic by xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba♦ Sep 14 at 6:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba♦ Sep 14 at 6:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – xzczd, Henrik Schumacher, Daniel Lichtblau, m_goldberg, Kuba
If this question can be reworded to fit the rules in the help center, please edit the question.







  • 3




    "I searched through different tutorials and documentation articles but haven't been able to find anything yet." Then you haven't yet learned the correct usage of document: i.stack.imgur.com/RVvvv.gif
    – xzczd
    Sep 13 at 17:28










  • @xzczd Thanks! I didn't actually know about that!
    – Jmeeks29ig
    Sep 13 at 17:30












  • 3




    "I searched through different tutorials and documentation articles but haven't been able to find anything yet." Then you haven't yet learned the correct usage of document: i.stack.imgur.com/RVvvv.gif
    – xzczd
    Sep 13 at 17:28










  • @xzczd Thanks! I didn't actually know about that!
    – Jmeeks29ig
    Sep 13 at 17:30







3




3




"I searched through different tutorials and documentation articles but haven't been able to find anything yet." Then you haven't yet learned the correct usage of document: i.stack.imgur.com/RVvvv.gif
– xzczd
Sep 13 at 17:28




"I searched through different tutorials and documentation articles but haven't been able to find anything yet." Then you haven't yet learned the correct usage of document: i.stack.imgur.com/RVvvv.gif
– xzczd
Sep 13 at 17:28












@xzczd Thanks! I didn't actually know about that!
– Jmeeks29ig
Sep 13 at 17:30




@xzczd Thanks! I didn't actually know about that!
– Jmeeks29ig
Sep 13 at 17:30










2 Answers
2






active

oldest

votes

















up vote
10
down vote



accepted










FullForm will show you how an expression is really interpreted,



In[5]:= FullForm[_.]

Out[5]= Optional[Blank]


This tells you you need to look at Optional and Blank to understand this particular syntax.



This is especially important for infix operators like this, because for some the F1 documentation search doesn't bring up a relevant page. Take the expression



x // f


or



f @ x


Running FullForm on either of these returns f[x] - telling you immediately what the notation means. This is good because if you highlight the @ or // and hit F1 you will find Prefix and Postfix, which aren't very helpful for understanding what those symbols mean. But FullForm will tell you how your syntax is interpreted by the front end, and what it is sent to the kernel as.






share|improve this answer






















  • Thanks! I'm still learning some of the basics, I should have thought to use FullForm :)
    – Jmeeks29ig
    Sep 13 at 17:36






  • 1




    @Jmeeks29ig - glad to help!
    – Jason B.
    Sep 14 at 1:45










  • I messed up when first commenting on this, so I cannot claim that the answer is trivial (and I wish the question hadn't been closed). It would be useful to include a few examples about how Optional is used. So far we learnt that _. is one shorthand for Optional. The more common shorthand is :, e.g. x_ : defaultValue. With this pattern, the name x will be assigned the explicitly written defaultValue. With f[x_.], the value of x will be taken from Default[f]. Here it is necessary to have the enclosing symbol f.
    – Szabolcs
    Sep 14 at 11:59

















up vote
2
down vote













I'm not sure if this fully answers the question I posted, but after some more searching, I have discovered that it seems like _. evaluates to Optional, at least when using ReplaceAll. An example will be better than words:



_, _. /. _Blank -> g


evaluates to:



g, Optional[g]


I know this is not a full answer, but hopefully it is at least partially helpful.






share|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    10
    down vote



    accepted










    FullForm will show you how an expression is really interpreted,



    In[5]:= FullForm[_.]

    Out[5]= Optional[Blank]


    This tells you you need to look at Optional and Blank to understand this particular syntax.



    This is especially important for infix operators like this, because for some the F1 documentation search doesn't bring up a relevant page. Take the expression



    x // f


    or



    f @ x


    Running FullForm on either of these returns f[x] - telling you immediately what the notation means. This is good because if you highlight the @ or // and hit F1 you will find Prefix and Postfix, which aren't very helpful for understanding what those symbols mean. But FullForm will tell you how your syntax is interpreted by the front end, and what it is sent to the kernel as.






    share|improve this answer






















    • Thanks! I'm still learning some of the basics, I should have thought to use FullForm :)
      – Jmeeks29ig
      Sep 13 at 17:36






    • 1




      @Jmeeks29ig - glad to help!
      – Jason B.
      Sep 14 at 1:45










    • I messed up when first commenting on this, so I cannot claim that the answer is trivial (and I wish the question hadn't been closed). It would be useful to include a few examples about how Optional is used. So far we learnt that _. is one shorthand for Optional. The more common shorthand is :, e.g. x_ : defaultValue. With this pattern, the name x will be assigned the explicitly written defaultValue. With f[x_.], the value of x will be taken from Default[f]. Here it is necessary to have the enclosing symbol f.
      – Szabolcs
      Sep 14 at 11:59














    up vote
    10
    down vote



    accepted










    FullForm will show you how an expression is really interpreted,



    In[5]:= FullForm[_.]

    Out[5]= Optional[Blank]


    This tells you you need to look at Optional and Blank to understand this particular syntax.



    This is especially important for infix operators like this, because for some the F1 documentation search doesn't bring up a relevant page. Take the expression



    x // f


    or



    f @ x


    Running FullForm on either of these returns f[x] - telling you immediately what the notation means. This is good because if you highlight the @ or // and hit F1 you will find Prefix and Postfix, which aren't very helpful for understanding what those symbols mean. But FullForm will tell you how your syntax is interpreted by the front end, and what it is sent to the kernel as.






    share|improve this answer






















    • Thanks! I'm still learning some of the basics, I should have thought to use FullForm :)
      – Jmeeks29ig
      Sep 13 at 17:36






    • 1




      @Jmeeks29ig - glad to help!
      – Jason B.
      Sep 14 at 1:45










    • I messed up when first commenting on this, so I cannot claim that the answer is trivial (and I wish the question hadn't been closed). It would be useful to include a few examples about how Optional is used. So far we learnt that _. is one shorthand for Optional. The more common shorthand is :, e.g. x_ : defaultValue. With this pattern, the name x will be assigned the explicitly written defaultValue. With f[x_.], the value of x will be taken from Default[f]. Here it is necessary to have the enclosing symbol f.
      – Szabolcs
      Sep 14 at 11:59












    up vote
    10
    down vote



    accepted







    up vote
    10
    down vote



    accepted






    FullForm will show you how an expression is really interpreted,



    In[5]:= FullForm[_.]

    Out[5]= Optional[Blank]


    This tells you you need to look at Optional and Blank to understand this particular syntax.



    This is especially important for infix operators like this, because for some the F1 documentation search doesn't bring up a relevant page. Take the expression



    x // f


    or



    f @ x


    Running FullForm on either of these returns f[x] - telling you immediately what the notation means. This is good because if you highlight the @ or // and hit F1 you will find Prefix and Postfix, which aren't very helpful for understanding what those symbols mean. But FullForm will tell you how your syntax is interpreted by the front end, and what it is sent to the kernel as.






    share|improve this answer














    FullForm will show you how an expression is really interpreted,



    In[5]:= FullForm[_.]

    Out[5]= Optional[Blank]


    This tells you you need to look at Optional and Blank to understand this particular syntax.



    This is especially important for infix operators like this, because for some the F1 documentation search doesn't bring up a relevant page. Take the expression



    x // f


    or



    f @ x


    Running FullForm on either of these returns f[x] - telling you immediately what the notation means. This is good because if you highlight the @ or // and hit F1 you will find Prefix and Postfix, which aren't very helpful for understanding what those symbols mean. But FullForm will tell you how your syntax is interpreted by the front end, and what it is sent to the kernel as.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 14 at 1:43

























    answered Sep 13 at 17:34









    Jason B.

    46.2k383178




    46.2k383178











    • Thanks! I'm still learning some of the basics, I should have thought to use FullForm :)
      – Jmeeks29ig
      Sep 13 at 17:36






    • 1




      @Jmeeks29ig - glad to help!
      – Jason B.
      Sep 14 at 1:45










    • I messed up when first commenting on this, so I cannot claim that the answer is trivial (and I wish the question hadn't been closed). It would be useful to include a few examples about how Optional is used. So far we learnt that _. is one shorthand for Optional. The more common shorthand is :, e.g. x_ : defaultValue. With this pattern, the name x will be assigned the explicitly written defaultValue. With f[x_.], the value of x will be taken from Default[f]. Here it is necessary to have the enclosing symbol f.
      – Szabolcs
      Sep 14 at 11:59
















    • Thanks! I'm still learning some of the basics, I should have thought to use FullForm :)
      – Jmeeks29ig
      Sep 13 at 17:36






    • 1




      @Jmeeks29ig - glad to help!
      – Jason B.
      Sep 14 at 1:45










    • I messed up when first commenting on this, so I cannot claim that the answer is trivial (and I wish the question hadn't been closed). It would be useful to include a few examples about how Optional is used. So far we learnt that _. is one shorthand for Optional. The more common shorthand is :, e.g. x_ : defaultValue. With this pattern, the name x will be assigned the explicitly written defaultValue. With f[x_.], the value of x will be taken from Default[f]. Here it is necessary to have the enclosing symbol f.
      – Szabolcs
      Sep 14 at 11:59















    Thanks! I'm still learning some of the basics, I should have thought to use FullForm :)
    – Jmeeks29ig
    Sep 13 at 17:36




    Thanks! I'm still learning some of the basics, I should have thought to use FullForm :)
    – Jmeeks29ig
    Sep 13 at 17:36




    1




    1




    @Jmeeks29ig - glad to help!
    – Jason B.
    Sep 14 at 1:45




    @Jmeeks29ig - glad to help!
    – Jason B.
    Sep 14 at 1:45












    I messed up when first commenting on this, so I cannot claim that the answer is trivial (and I wish the question hadn't been closed). It would be useful to include a few examples about how Optional is used. So far we learnt that _. is one shorthand for Optional. The more common shorthand is :, e.g. x_ : defaultValue. With this pattern, the name x will be assigned the explicitly written defaultValue. With f[x_.], the value of x will be taken from Default[f]. Here it is necessary to have the enclosing symbol f.
    – Szabolcs
    Sep 14 at 11:59




    I messed up when first commenting on this, so I cannot claim that the answer is trivial (and I wish the question hadn't been closed). It would be useful to include a few examples about how Optional is used. So far we learnt that _. is one shorthand for Optional. The more common shorthand is :, e.g. x_ : defaultValue. With this pattern, the name x will be assigned the explicitly written defaultValue. With f[x_.], the value of x will be taken from Default[f]. Here it is necessary to have the enclosing symbol f.
    – Szabolcs
    Sep 14 at 11:59










    up vote
    2
    down vote













    I'm not sure if this fully answers the question I posted, but after some more searching, I have discovered that it seems like _. evaluates to Optional, at least when using ReplaceAll. An example will be better than words:



    _, _. /. _Blank -> g


    evaluates to:



    g, Optional[g]


    I know this is not a full answer, but hopefully it is at least partially helpful.






    share|improve this answer
























      up vote
      2
      down vote













      I'm not sure if this fully answers the question I posted, but after some more searching, I have discovered that it seems like _. evaluates to Optional, at least when using ReplaceAll. An example will be better than words:



      _, _. /. _Blank -> g


      evaluates to:



      g, Optional[g]


      I know this is not a full answer, but hopefully it is at least partially helpful.






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        I'm not sure if this fully answers the question I posted, but after some more searching, I have discovered that it seems like _. evaluates to Optional, at least when using ReplaceAll. An example will be better than words:



        _, _. /. _Blank -> g


        evaluates to:



        g, Optional[g]


        I know this is not a full answer, but hopefully it is at least partially helpful.






        share|improve this answer












        I'm not sure if this fully answers the question I posted, but after some more searching, I have discovered that it seems like _. evaluates to Optional, at least when using ReplaceAll. An example will be better than words:



        _, _. /. _Blank -> g


        evaluates to:



        g, Optional[g]


        I know this is not a full answer, but hopefully it is at least partially helpful.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 13 at 17:29









        Jmeeks29ig

        56929




        56929












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay