Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Multiple iterators' topicStudent Support Forum > General > "Multiple iterators"

Next Comment >Help | Reply To Topic
Author Comment/Response
09/22/04 01:30am

Hi all,

Normally, to get a double sum, I'd use something like this:

Sum[a[i,j], {i,1,3}, {j,1,3}]

However, I have a function (a module, really) where the number of iteration variables depends on the input. I can construct a list which has the right form, but it obviously doesn't work. Here's the 2-variable example:

Sum[a[i,j], {{i,1,3},{j,1,3}}]

It fails because {{i,1,3},{j,1,3}} isn't really an iterator. It just looks like one. :)

Is there _any_ elegant way to compute a sum (or table, product, etc) when you don't know in advance how many iterators there will be? More generally, is there any way to construct an iterator sequence?

I've been all through the online help and google, and I haven't found anything yet...


URL: ,

Subject (listing for 'Multiple iterators')
Author Date Posted
Multiple iterators Mike 09/22/04 01:30am
Re: Multiple iterators Henry Lamb 09/22/04 7:28pm
Re: Multiple iterators Mike 09/27/04 4:38pm
Next Comment >Help | Reply To Topic