       Re: Function to handle array with variable _number_ of dimensions?

• To: mathgroup at smc.vnet.net
• Subject: [mg58530] Re: [mg58509] Function to handle array with variable _number_ of dimensions?
• From: Sseziwa Mukasa <mukasa at jeol.com>
• Date: Wed, 6 Jul 2005 03:11:15 -0400 (EDT)
• References: <200507050557.BAA29447@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Jul 5, 2005, at 1:57 AM, Joe Christy wrote:

> I'd like to write a function that takes two integer arguments, P and Q
> say, and then returns a value calculated from the P x P x ... x P (Q
> factors) array, whose entries depend on both P and Q. My first impulse
> is to try and iterate over the array, but I don't see how to
> generate a
>  non-fixed number of iteration variables.
>
> Does anyone have a suggestion of a good way to do this, short of
> writing
> a a distinct variant function for each possible value of Q?

Your question is unclear, do you have a Q dimensional array that you
are extracting elements from, or a 1 dimensional array that you are
extracting the P^Qth element from?  Incidentally you probably should
use lower case variables.

If it's the first case just use Table

arr[[Sequence@@Table[p,{q}]]]

will extract the element p,p,...p repeated q times of arr.

Regards,

Ssezi

```

• Prev by Date: Re: Any ideas about solving an underdetermined system?
• Next by Date: Wrong Integral result for a Piecewise function
• Previous by thread: Function to handle array with variable _number_ of dimensions?
• Next by thread: Re: Function to handle array with variable _number_ of dimensions?