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

MathGroup Archive 2007

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

Search the Archive

Re: Outer with index in bounds

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80451] Re: Outer with index in bounds
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 23 Aug 2007 00:57:11 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fagu1f$92b$1@smc.vnet.net>

DC wrote:

> Hi all, I would like to use Outer as:
> 
> Outer[f[#1,#2]&,Range[10],Range[#1],1,1]
> 
> in order to create a list whose first element is a list of length 1, the 
> second is a list of length 2, and so on.
> More generally, I would like to use Outer with one bound depending on 
> the other as in :
> 
> Outer[f[#1,#2]&,list1,list2[#1],1,1]
> 
> Obviously none of the above works.

Note that your original expressions are missing one '&' character. 
Moreover, *Outer* does not pass any parameter to its second argument 
onwards. So, assuming I have correctly understood what you want, the 
following will do it:

In[1]:= Outer[f[#1, #2] &, Range[3], Range[#1], 1, 1] & /@ Range[3]

Out[1]= {{{f[1, 1]}, {f[2, 1]}, {f[3, 1]}}, {{f[1, 1],
    f[1, 2]}, {f[2, 1], f[2, 2]}, {f[3, 1], f[3, 2]}}, {{f[1, 1],
    f[1, 2], f[1, 3]}, {f[2, 1], f[2, 2], f[2, 3]}, {f[3, 1], f[3, 2],
    f[3, 3]}}}

-- 
Jean-Marc


  • Prev by Date: Re: Redefine Arg to return a value from 0 to 2 pi
  • Next by Date: Re: getting data for Histogram
  • Previous by thread: Re: Outer with index in bounds
  • Next by thread: REQ: Kuratowski graphs on Möbius band and torus