Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

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

Search the Archive

Re: := vs. =

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8907] Re: [mg8858] := vs. =
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Thu, 2 Oct 1997 22:56:59 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Frank Roescher <froesche at dekalb.dc.peachnet.edu>
[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  
value(value(rhs)).

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 haystack.demon.co.uk
http://www.haystack.demon.co.uk/training.html
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. =