Re: Question about UpSet vs SetDelayed
- To: mathgroup at smc.vnet.net
- Subject: [mg63797] Re: [mg63751] Question about UpSet vs SetDelayed
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 14 Jan 2006 02:33:12 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Andy, I think the principal difference is where the function is stored. someFunc[s] := True; someOtherFunc[s] ^= True; ?? s Global`s someOtherFunc[s] ^= True ?? someFunc Global`someFunc someFunc[s] := True ?? someOtherFunc Global`someOtherFunc If someOtherFunc was call many times (with additional Set definitions), but hardly ever with s, then Mathematica wouldn't waste time looking at the special s definition every time it was called. Or someOtherFunc might be a protected function that you don't wish to alter. Maybe you will get some more complete answers. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Andy Somogyi [mailto:andy_somogyi at hotmail.com] To: mathgroup at smc.vnet.net Hello I'm trying to work out what how exactly := and ^= differ and what are uses for ^=. Say I want to have some 'properties' of a symbol 's', I can do: someFunc[s] := True; and I can also do: someOtherFunc[s] ^= True; When I execute either, someFunc[s] and someOtherFunc[s], they both obviously return True, and when I apply them to some other symbol or value for which they are not defined for, they both obviously return the expected result: In[20]:= someFunc[SomethingOtherThanS] Out[20]:= someFunc[SomehingOtherThanS] and In[20]:= someOtherFunc[SomethingOtherThanS] Out[20]:= someOtherFunc[SomehingOtherThanS] So, both := and ^= aperently behave very similarly, so my question how exactly do they differ and in what cases should I use one over the other? thanks