Read Online
Download PDF
Additional resources
Revision history
Known typos/bugs
Report a bug
License terms
About the author
"node502_1.gif" "node502_2.gif" "node502_3.gif"     Using  Outer in more complicated cases: a caution

Outer may be used in more general setting, in particular when the input lists are not simple, but nested lists. There is one specific instance of that case which I would like to discuss now.


Consider the following situation:



This output is not what one would immediately expect. What if I want to get my function <f> applied to the sublists, like {{f[{1,2},{5,6}],...}}. To achieve this, we have to tell Outer that it should treat sublists as individual elements. This is done by specifying elements on which level of the input lists (first in this case) should be treated as individual elements:



Now we get what we wanted. In this particular case, another possibility to get it is to use Distribute:



For more details on Distribute, consult Mathematica  Help and Mathematica  Book.

"node502_11.gif" "node502_12.gif" "node502_13.gif"

Created by Wolfram Mathematica 6.0  (05 February 2009) Valid XHTML 1.1!