Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Building a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47131] Re: Building a list
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Sat, 27 Mar 2004 01:34:34 -0500 (EST)
  • References: <c40sfi$mp8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Outer is what you want

xlist={x1,x2,x3};

Outer[f[a,b,#1,#2]&, xlist, xlist ]

{{f[a, b, x1, x1], f[a, b, x1, x2], f[a, b, x1, x3]}, 
  {f[a, b, x2, x1], f[a, b, x2, x2], f[a, b, x2, x3]}, 
  {f[a, b, x3, x1], f[a, b, x3, x2], f[a, b, x3, x3]}}


Bob Hanlon

In article <c40sfi$mp8$1 at smc.vnet.net>, Mark Coleman <mark at markscoleman.com>
wrote:

<< I've got a relatively simple function f[a_,b_,c_,d_], where a and b are  
integers and c and d are lists (of reals), and f returns a real.

I need to evaluate f on (potentially long) sets of lists and calculate  
a square "matrix" from the possible permutations of the elements in the  
lists. For instance

If

xlist={x1,x2,x3}


I need to calculate

{{f[a,b,x1,x1],f[a,b,x1,x2],f[a,b,x1,x3]},{f[a,b,x2,x1],f[a,b,x2,x2],f[a 
,b,x2,x3]},{f[a,b,x3,x1],f[a,b,x3,x2],f[a,b,x3,x3]}}

Note that f[a,b,c,d] does not equal f[a,b,d,c].

My first reaction was that Outer[] might do this, but I cannot seem to  
get it to work. I'd appreciate any suggestions.


  • Prev by Date: Re: Building a list
  • Next by Date: Re: Building a list
  • Previous by thread: Re: Building a list
  • Next by thread: Re: Building a list