Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

question

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: question
  • From: "Paul N. Schatz" <pns at fermi.clas.virginia.edu>
  • Date: Fri, 16 Oct 92 15:35:24 -0400

Thread[If[{aa>10,bb>10,cc>10},{4,5,6},{7,8,9}]]
out=
{If[aa > 10, 4, 7], If[bb > 10, 5, 8], If[cc > 10, 6, 9]}

(*  BUT!!  *)

list={aa,bb,cc}
out=
{aa, bb, cc}

list=Thread[list>{10,10,10}]
out=
{aa > 10, bb > 10, cc > 10}

Thread[If[list,{4,5,6},{7,8,9}]]
out=
{If[list, 4, 7], If[list, 5, 8], If[list, 6, 9]}
(* And it doesn't seem to work because I
   gave the list a name!  *)

(* However  *)

Thread[If[Evaluate[list],{4,5,6},{7,8,9}]]
out=
{If[aa > 10, 4, 7], If[bb > 10, 5, 8], If[cc > 10, 6, 9]}
(* And now it works!  *)

(* Why does giving the list a name make a difference?  *)


-- 
Paul N. Schatz
Chemistry Department
University of Virginia
McCormick Road
Charlottesville, VA 22901, USA
phone: 804-924-3249
email: pns at virginia.edu





  • Prev by Date: Quadra and Mma
  • Next by Date: Inequalities
  • Previous by thread: Quadra and Mma
  • Next by thread: Inequalities