# More elegant/efficient solution to browse through an array

I have an array of lists and want to correlate every list with each other like this:

Table[Table[Correlation[list[[y]], list[[x]]], {x, 1, Length[list]}], {y,1, Length[list]}];


I take the first list and correlate it with all others asf. I pretty much assume, this is not a very elegant and efficient code, so I wanted to ask for some alternatives. How would you guys do it?

-
list = Permutations@Range@3; Correlation @@@ Subsets[list, {2}] ? –  belisarius Jan 30 '14 at 17:29
Possibly related and/or helpful: mathematica.stackexchange.com/q/8928/121 –  Mr.Wizard Jan 31 '14 at 6:51

It's not entirely clear to me what you mean by "browse through an array" but from my best guess you might try:

array = RandomInteger[9, {50, 50}];

Pane[TableForm @ array, {500, 400}, Scrollbars -> True]


Since this is not the meaning you intended here is another:

list = {a, b, c, d};

Outer[f, list, list]

{{f[a, a], f[a, b], f[a, c], f[a, d]},
{f[b, a], f[b, b], f[b, c], f[b, d]},
{f[c, a], f[c, b], f[c, c], f[c, d]},
{f[d, a], f[d, b], f[d, c], f[d, d]}}

f @@@ Tuples[list, 2]

 {f[a, a], f[a, b], f[a, c], f[a, d], f[b, a], f[b, b], f[b, c], f[b, d],
f[c, a], f[c, b], f[c, c], f[c, d], f[d, a], f[d, b], f[d, c], f[d, d]}


Note that Outer produces a table of values (nested lists) while Tuples produces a flat list.

-
or ArrayPlot[array, ColorFunction -> "Rainbow"] for the more visual people out there :) –  Pinguin Dirk Jan 30 '14 at 16:39
@PinguinDirk Of course that would be better for numeric data; this is intended as a generic method, where elements are arbitrary expressions. –  Mr.Wizard Jan 30 '14 at 16:40
sure, just kidding - one can only guess what he wants, at this point –  Pinguin Dirk Jan 30 '14 at 16:41
Sorry, don't know how to call it. I meant getting to every value of the array, e.g. for multiplying or correlating all values of an array with each other. –  holistic Jan 30 '14 at 16:47
@Mr.Wizard I think he means "browse" as in the Scan sense... walk through the list. What OP wants is just Outer[Correlation, list, list] (possibly fix levels... didn't try), which is most likely a millionth duplicate. –  rm -rf Jan 30 '14 at 17:13

Another option might be to use TableView This gives the row number and column number on the sides as well. This is undocumented still as of Version 9.01, but it is there.

array = RandomInteger[9, {50, 50}];
TableView[array]


-
I see they've improved TableView since v7; looks nice. +1 –  Mr.Wizard Jan 31 '14 at 6:52

I would do it like this:

Correlation @ Transpose @ list

-