MathGroup Archive 2005

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

Search the Archive

Re: multiple choice IF condition


marloo3 at mail15.com wrote:

> could we have a more practical way than this way of choosing some
> numbers of the choice:
> 
> a = 0;
> Table[If[i == 3 || i == 5 || i == 9 || i==18, a = a + i], {i, 20}]
> 
> ie: i wish if it is possible like this:
> If[i==3 ||5 ||9||18, ...]


If[MemberQ[{3, 5, 9, 18}, i], ...]


Regards,
Marcus

-- 
It is awfully hard work doing nothing. -- Oscar Wilde


  • Prev by Date: Re: multiple choice IF condition
  • Next by Date: Compile. Not again
  • Previous by thread: Re: Re: multiple choice IF condition
  • Next by thread: Re: multiple choice IF condition