Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: rookie code issue
Posted:
Mar 21, 2013 12:55 AM


According to the reference page for Which:
If any of the Subscript[test, i] evaluated by Which give neither True nor False, then a Which object containing these remaining elements is returned unevaluated.
So look at the following result:
Cos == Sin
You'll get back as output:
Cos == Sin
which is neither True nor False. On the other hand,
Cos === Sin (* using SameQ now *)
gives result False. Hence
m = Cos; Which[m === Sin, 5, m === Cos, 2]
does give the result 2 that you wanted.
On Mar 20, 2013, at 4:22 AM, robholman@gmail.com wrote:
> ...Why doesn't the following code return a 2? > > > m = Cos; > Which[m == Sin, 5, m == Cos, 2]
 Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 5491020 (H) University of Massachusetts 413 5452838 (W) 710 North Pleasant Street fax 413 5451801 Amherst, MA 010039305



