Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: dynamic nested loops

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122860] Re: dynamic nested loops
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 12 Nov 2011 07:36:54 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j9irsq$8g5$1@smc.vnet.net>

Am 11.11.2011 11:03, schrieb Ron:
>... I could construct a list {{i,imin,imax},{j, jmin, jmax}, ...{}} but "Sum" doen't know what to do with the outside braces{...}.
> ANy suggestions would be much appreciated.
>

If you've got such a list, let "Apply" remove the the outer curly braces ;-)

e.g.:
In[1]:= Sum[f[i,j,k],##]& @@ {{i, 1, 3}, {j, 1, 2}, {k, 5, 4, -1}}
Out[1]= f[1, 1, 4] + f[1, 1, 5] + f[1, 2, 4] + f[1, 2, 5] + f[2, 1, 4] + 
f[2, 1, 5] + f[2, 2, 4] + f[2, 2, 5] + f[3, 1, 4] + f[3, 1, 5] + f[3, 2, 
4] + f[3, 2, 5]



  • Prev by Date: Re: Pattern to match element in nested list
  • Next by Date: Re: Simple DSolve equation
  • Previous by thread: Re: dynamic nested loops
  • Next by thread: Re: dynamic nested loops