0
$\begingroup$

I have a undefined function $\phi[i,j]$ where $i=0,1,...,m$ and $i=0,1,...,n$.

How can I generate this list:

{$\phi[0,0],\phi[1,0],...,\phi[m,0],\phi[0,1],\phi[1,1],...\phi[m,1],\phi[0,2],...,\phi[m,n]$}

where I have all the iterations of $i$ and $j$ on the $\phi$ function?

$\endgroup$
  • 3
    $\begingroup$ Try Array, for example: Flatten[Array[f, {5, 4}]] $\endgroup$ – bill s May 15 '19 at 20:31
  • 1
    $\begingroup$ Perhaps Tuples[φ[Range[0, 3], Range[0, 2]]] $\endgroup$ – Carl Woll May 15 '19 at 20:34
3
$\begingroup$

It's as straightforward as:

m = 10;
n = 10;
Flatten[Table[f[i, j], {i, 1, m}, {j, 1, n}]]

(*{f[1, 1], f[1, 2], f[1, 3], f[1, 4], f[1, 5], f[1, 6], f[1, 7], 
  f[1, 8], f[1, 9], f[1, 10], f[2, 1], f[2, 2], f[2, 3], f[2, 4], 
  f[2, 5], f[2, 6], f[2, 7], f[2, 8], f[2, 9], f[2, 10], f[3, 1], 
  f[3, 2], f[3, 3], f[3, 4], f[3, 5], f[3, 6], f[3, 7], f[3, 8], 
  f[3, 9], f[3, 10], f[4, 1], f[4, 2], f[4, 3], f[4, 4], f[4, 5], 
  f[4, 6], f[4, 7], f[4, 8], f[4, 9], f[4, 10], f[5, 1], f[5, 2], 
  f[5, 3], f[5, 4], f[5, 5], f[5, 6], f[5, 7], f[5, 8], f[5, 9], 
  f[5, 10], f[6, 1], f[6, 2], f[6, 3], f[6, 4], f[6, 5], f[6, 6], 
  f[6, 7], f[6, 8], f[6, 9], f[6, 10], f[7, 1], f[7, 2], f[7, 3], 
  f[7, 4], f[7, 5], f[7, 6], f[7, 7], f[7, 8], f[7, 9], f[7, 10], 
  f[8, 1], f[8, 2], f[8, 3], f[8, 4], f[8, 5], f[8, 6], f[8, 7], 
  f[8, 8], f[8, 9], f[8, 10], f[9, 1], f[9, 2], f[9, 3], f[9, 4], 
  f[9, 5], f[9, 6], f[9, 7], f[9, 8], f[9, 9], f[9, 10], f[10, 1], 
  f[10, 2], f[10, 3], f[10, 4], f[10, 5], f[10, 6], f[10, 7], f[10, 8],
  f[10, 9], f[10, 10]} *)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.