MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: := vs. =

  • To: mathgroup at
  • Subject: [mg8907] Re: [mg8858] := vs. =
  • From: Allan Hayes <hay at>
  • Date: Thu, 2 Oct 1997 22:56:59 -0400
  • Sender: owner-wri-mathgroup at

Frank Roescher <froesche at>
[mg8858] := vs. =

> When I define a function on Mathematica, I use f[x_]=xxxxx, without
> using a colon.  It seems to work just fine.  Is there a risk in
> leaving out the colon?

The difference is simply that

f[x_] := rhs  causes   f[x_] := rhs  to be stored and outputs Null
f[x_] = rhs  causes   f[x_] := value(rhs)  to be stored and outputs  

Why one or the other?

f1[x_] = Integrate[1/(1+t^3), {t,0,y}]
to get the integration done once when the rule is stored rather  
than  every time it is used.

f2[x_] := Expand[x]
to store f2[x_] := Expand[x] rather than f2[x_] := x, which would  
give f2[(a+b)^2] -> (a+b)^2 instead of a^2+2ab+b^2

Allan Hayes
hay at
voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester,  UK

  • Prev by Date: Re: Sequence is funny !
  • Next by Date: Re: trig expansion
  • Previous by thread: Re: := vs. =
  • Next by thread: RE: := vs. =