This is essentially asking how to do a case switch in LaTeX. I want to define a macro so that if the argument passed is one thing, then something happens, and if not then something else happens. I know ways to hack this, but they do feel very hacky. What I currently use is something like:
\newcommand{\my@testcase}{world}
\newcommand{\hello}[1]{%
\edef\my@temp{#1}%
\ifx\my@temp\my@testcase
Greetings%
\else
Hello%
\fi
}
It's a pain to nest (though I suppose one could be clever with loops) and it seems a bit overkill to have to define two macros in order to test if they expand to the same thing. So: what's the cleanest way to do this (for preference in LaTeX2e, though as I'm starting to use a bit of expl3 then I'd be happy to learn about that too, and of course answers explaining how easy this is in other variants are equally welcome)?
(Edit in response to Joseph's comment, part of the problem is that I don't know what all those words mean!): Here's my "real world" example. Using the unicode-math package, I've colour coded lots of letters so that the colour (and style) links to what it is. That's fine, except that sometimes a letter or number plays more than one role. So I have a command that can do a one-time switch. The problem is that these one-time switches appear to be very expensive (my document compilation time went up to about 20minutes on a new machine). So for the most common ones, I've found a way around the one-time switch - the best example being that 0 is sometimes a real number, sometimes a vector, and sometimes a function. But as far as the document is concerned, it's still a one-time switch: that is \vect{0} and \vect{x} both say "Do a one-time switch to typeset 0 (or x) as a vector", but \vect{0} implements the "way round" whilst \vect{x} does the expensive switch.
So all I'm passing to the macro are characters, but I'd like it to be robust enough that if a passed it something longer then it Did The Right Thing without complaining.
(Is that clearer?)
Oh, and I'm using TeXLive 2010.

\pdfstrcmp? – Joseph Wright Sep 20 '10 at 18:37\vect{0}implements the 'way round' whilst\vect{x}does the expensive switch." I don't really know what Right Thing (tm) you want done. – TH. Sep 20 '10 at 19:35\vect{0}expands to0whilst\vect{anything else}expands to\mathbf{anything else}. The 'Right Thing' means that the "anything else" can truly be "anything else". – Andrew Stacey Sep 20 '10 at 20:06