0
$\begingroup$

I am going through the Fast introduction for programmers tutorial on Mathematica. The page on patterns has the below line:

x_ (short for x:_) stands for a pattern whose value will be named x

shouldn't it be '(short for x:=_)' which would suggest that pattern matched by _ will be bound to the variable x?

$\endgroup$
  • 1
    $\begingroup$ No, not a typo; compare the results of FullForm[x_] and FullForm[x : _]. $\endgroup$ – J. M. is away Sep 24 '18 at 20:36
  • 1
    $\begingroup$ Also, please do not use the bugs tag until other people have already confirmed that it is one. $\endgroup$ – J. M. is away Sep 24 '18 at 20:37
3
$\begingroup$

: and := are two different operations in Mathematica. :, shorthand for Pattern, is used to represent some form, while :=, short for SetDelayed is used to say "Okay, replace any instance of the left hand side with the right hand side and re-evaluate rhs at every replacement".

In the context of x_ vs x:=_, x_ is syntactically/manifestly equivalent to x:_ or x:Blank[] (i.e. Represent by x any single entity.), whereas x:=_ represents "At every occurrence of anything of the form x replace it with the pattern object Blank[]".

x := _; x
Clear@x; x : _

_

x_

$\endgroup$
  • $\begingroup$ Thanks for editing the question. The question makes sense now and can help others too. $\endgroup$ – gaganso Sep 24 '18 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.