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


Use this:
Which[m === Sin, 5, m === Cos, 2]
and read up on the difference between '==' and '==='
On Wed, Mar 20, 2013 at 1:22 AM, <robholman@gmail.com> wrote:
> Hi folks: > > I'm working on a bit of code in which I want students to choose a trig > function from a dropdown menu, and then from there have some choices for > viewing the graph. All is working fine except for one thing. There are a > couple of constants that depend on the function they choose from the menu, > and I'm trying to define the constant based on their choice for f. The > basic issue I'm having boils down to the following question: > > Why doesn't the following code return a 2? > > > m = Cos; > Which[m == Sin, 5, m == Cos, 2] > > > > Thanks for the help! > > Rob > >



