Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Setting upvalues, using ^:=, such that they get actually used

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96363] Setting upvalues, using ^:=, such that they get actually used
  • From: Niko <niko.schwarz at googlemail.com>
  • Date: Thu, 12 Feb 2009 06:37:35 -0500 (EST)

Ok, I stumbled across Upvalues today and I thought they were gorgeous
for my case.

My case is this: I need the intersection of two really large sets, it
looks like this:

Intersection[sym[l], sym[q]]

Now, they are really two large to compute them. I can compute the
intersection faster myself. So, I tossed along and defined something
like this:


Intersection[sym[a_], sym[b_]] ^:= 42

Unfortunately, Mathematica has a strong preference for using the
downvalue of sym for the computation, regardless of the order I use
for input.

If I undefine "sym", things work fine, but that is of course a whole
lot less elegant. Is there a way to "push" the priority of the upvalue
definition, so it gets used whenever possible?

Kindest regards,

Niko


  • Prev by Date: Re: Logarithmic Plot
  • Next by Date: Re: switching axes in Plot?
  • Previous by thread: Re: User interface version 7: Alt Gr issue
  • Next by thread: Re: Setting upvalues, using ^:=, such that they get actually used