MathGroup Archive 2009

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

Search the Archive

Re: Is it possible to impose a condition on an iterator of

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101571] Re: [mg101499] Is it possible to impose a condition on an iterator of
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Fri, 10 Jul 2009 06:46:35 -0400 (EDT)
  • References: <200907090552.BAA16854@smc.vnet.net>

A follow - up to my previous post (particularly the conditionalSum function):
there is of course a much simpler and much faster solution:

ClearAll[conditionalSumAlt];
SetAttributes[conditionalSumAlt, HoldAll];
conditionalSumAlt[expr_, test_, iterators__] :=
  Sum[expr*If[test, 1, 0], iterators];

Perhaps, I have been playing too much with introspection recently. Sorry if
that was confusing.

Best,
Leonid


On Wed, Jul 8, 2009 at 10:52 PM, Mauro <mauro at nonoyahoo.com> wrote:

> I would like to perform a summation of this type,
>
> Sum[a^2 - 3 a/(4 a^2), {a, 1, 20}]
>
> excluding however some values of the iteratore, I would for instance
> like to exclude the values than to greater of 6 and inferior to 12. Is
> it possible?
>
> Thanks
>
>



  • Prev by Date: Re: Is it possible to impose a condition on an iterator of
  • Next by Date: Re: Selecting Rows Based on Column Values
  • Previous by thread: Re: Is it possible to impose a condition on an iterator of
  • Next by thread: RE: Is it possible to impose a condition on an iterator