MathGroup Archive 2005

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

Search the Archive

Re: multiple choice IF condition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56437] Re: [mg56427] multiple choice IF condition
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Tue, 26 Apr 2005 01:32:38 -0400 (EDT)
  • References: <200504250530.BAA01448@smc.vnet.net>
  • Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

a = 0
Table[If[MatchQ[i, 3 | 9 | 10], a += 1], {i, 12}]
a

What happened to functional programing?

On 4/25/05, marloo3 at mail15.com <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, ...]
> 
> Thanks very much
> mark
> 
> 


-- 
Chris Chiasson
http://chrischiasson.com
Kettering University
Mechanical Engineering
Graduate Student
1 810 265 3161


  • Prev by Date: Re: Problem with MatchQ and SameQ
  • Next by Date: MapThread Replace?
  • Previous by thread: multiple choice IF condition
  • Next by thread: Re: multiple choice IF condition