MathGroup Archive 2002

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

Search the Archive

Generate all k-tuples

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36181] Generate all k-tuples
  • From: rdobrow at carleton.edu (Bob)
  • Date: Mon, 26 Aug 2002 04:15:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Is there an easy (elegant?) way to generate the set of all k-tuples
taking values from some set (list) S? I want the arguments of the
function to be k (the length of the tuples) and the set S. That is,
KTuples[3,{a,b}] should produce
{{a,a,a},{a,a,b},{a,b,a},{a,b,b},{b,a,a},{b,a,b},{b,b,a},{b,b,b}}.


  • Prev by Date: Variable functions
  • Next by Date: Re: Reducing a function to one argument
  • Previous by thread: RE: Variable functions
  • Next by thread: Re: Generate all k-tuples