MathGroup Archive 2010

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

Search the Archive

newbe question about Sting Comparison

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107010] newbe question about Sting Comparison
  • From: "Biff. Bartolemew" <harrytuttle777 at mac.com>
  • Date: Sun, 31 Jan 2010 05:58:58 -0500 (EST)

Hello,

I hope someone can help me out, and not laugh to hard at my stupidity, 
but, I am trying write a little program


playAGame[] := Module[
     {car},
     ans = Input["Would you like to play a game"];
     Print[ans];
     If[ans == "yes", Print["you answered yes"],
         Print["you did not answer yes"]
     ];
     If[5 == 5, Print["You suck"], Print["You Rock"]];

     ]

The first If statement does not seem to be evaluated.

Yet, if I type:
   "yes"=="yes",   I get the answer I am looking for.

It seems like the string comparison is acting different in the middle of 
the If statement.  Can someone tell me what I am doing wrong?


-Thanks


  • Prev by Date: Phase reversal at fixed boundary
  • Next by Date: Re: position of sequence of numbers in list
  • Previous by thread: Phase reversal at fixed boundary
  • Next by thread: Re: newbe question about Sting Comparison