MathGroup Archive 1994

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

Search the Archive

Why won't If[ ] evaluate?

  • To: mathgroup at
  • Subject: Why won't If[ ] evaluate?
  • From: jmm at
  • Date: Wed, 6 Jul 1994 15:51:17 -0700 (PDT)

I am trying to do a boolean test on each value in a vector.  I have figured
out how to use Map[ ] to set this up, with the return equal to a list of the
individual tests.  But when I do this, I get a list of If[ ] statements,
rather than a list of the results of evaluating those If[ ] statements.  Here
is the code:

        jlist = {1,-1};
	Map[If[# > 0,1,0],jlist]
    	If[jlist[[1]] > 0,1,0]

    	{If[#1 > 0, 1, 0][1], If[#1 > 0, 1, 0][-1]}

What I want Out[42] to look like is simply {1,0}, the results of evaluating
the two If[ ] expressions.  I've tried wrapping Evaluate[ ] around the If[ ],
and wrapping it around the first argument of If[ ] (i.e., Evaluate[# > 0]),
but neither worked.  What am I missing here?

Prof. Jeff MacKie-Mason	                
Dept. of Economics         Jan-July 28 '94: California Energy Institute
Univ. of Michigan                                     2539 Channing Way
Ann Arbor, MI 48109-1220                             Berkeley, CA 94720
internet: jmm at       phone: 510-642-3570     fax: 510-642-3570

  • Prev by Date: Re:Alternative to Timing[10000!] benchmark
  • Next by Date: Error(?) in Limit Evaluation
  • Previous by thread: Re: simplification of sums
  • Next by thread: Error(?) in Limit Evaluation