MathGroup Archive 2013

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

Search the Archive

Re: rookie code issue

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130218] Re: rookie code issue
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Thu, 21 Mar 2013 00:57:30 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20130320082258.D93A969F1@smc.vnet.net>

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 at gmail.com wrote:

> ...Why doesn't the following code return a 2?
>
>
> m = Cos;
> Which[m == Sin, 5, m == Cos, 2]

---
Murray Eisenberg                                    murray at math.umass.edu
Mathematics & Statistics Dept.      
Lederle Graduate Research Tower            phone 413 549-1020 (H)
University of Massachusetts                               413 545-2838 (W)
710 North Pleasant Street                         fax   413 545-1801
Amherst, MA 01003-9305








  • Prev by Date: Re: rookie code issue
  • Next by Date: RegionPlot and Show
  • Previous by thread: Re: rookie code issue
  • Next by thread: Re: rookie code issue