|
[Date Index]
[Thread Index]
[Author Index]
Re: := vs = in some function definitions
- To: mathgroup at smc.vnet.net
- Subject: [mg113277] Re: := vs = in some function definitions
- From: Andrea <btlgs2000 at gmail.com>
- Date: Thu, 21 Oct 2010 07:04:30 -0400 (EDT)
- References: <i9m7u7$j41$1@smc.vnet.net>
On Oct 20, 10:06 am, Sam Takoy <sam.ta... at yahoo.com> wrote:
> Hi,
>
> Have read everything I could find regarding delayed assignment, I'm
> still not quite sure when to use which.
>
> For example, in the definition
>
> f[x_] = IdentityMatrix[50].Append[Range[1, 49], x];
>
> could there ever be any reason to use := ?
>
> It seems that using := will condemn the function to repeated ext=
ra
> work every time its called. So could there be a situation where the use
> of ":=" for the above function is recommended?
>
> Many thanks in advance,
>
> Sam
Multiplying vector Append[Range[1, 49], x] with IdentityMatrix[50] is
useless cause you simply obtain Append[Range[1, 49], x].
Apart from this, considering your definition as a contrived example,
the = is in this case more efficient than := cause IdentityMatrix[50]
is calculated only once and so the multiplication and I see no
convenience in using :=
Prev by Date:
Re: := vs = in some function definitions
Next by Date:
Re: Table of tables
Previous by thread:
Re: := vs = in some function definitions
Next by thread:
Re: := vs = in some function definitions
|