# Apply function to output of previous function

I am trying to write a function that takes 3 tuples. Each tuple contains two lists which are first divided. This results in 3 lists. Then I want to take the Mean of all the columns. I can do this in two steps:

d = Divide[#1, #2] & @@@  { {{1, 2, 3}, {4, 5, 6}}  , {{7, 8, 9}, {10,
11, 12}} , {{13, 14, 15}, {16, 17, 18} } }
Mean[d]


However I would like to put this all on one line. I have tried a couple different things all smilar to

Mean[#] & @ Divide[#1, #2] & @@@  { {{1, 2, 3}, {4, 5, 6}}  , {{7, 8, 9}, {10,
11, 12}} , {{13, 14, 15}, {16, 17, 18} } }


The problem is the mean is not applied to the entire list but rather one level inside, which does not give the desired output.

the desired out put is:

{47/80, 608/935, 25/36}

-
Try the postfix // operator. So: ... // Mean –  mfvonh May 22 '14 at 18:45
closely related: when is f@g not the same as f[g] –  Kuba May 22 '14 at 18:50

## 1 Answer

list = {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}, {{13, 14,
15}, {16, 17, 18}}};

Mean[Divide @@@ #] &@ list

Composition[Mean, Divide @@@ # &]@list

Divide @@@ list // Mean

Mean[Divide @@@ list]

Mean @ (Divide @@@ list)


It seems that first and the second may be considered the best since you don't have to put anything after the list.

Take a look at the topic I've linked too.

-
Aesthetically, the last one is the nicest. –  eldo May 22 '14 at 19:08