MathGroup Archive 2009

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

Search the Archive

Re: generating submultisets with repeated elements

  • To: mathgroup at
  • Subject: [mg103681] Re: generating submultisets with repeated elements
  • From: David Bevan <david.bevan at>
  • Date: Fri, 2 Oct 2009 08:23:57 -0400 (EDT)
  • References: <>

I've now tried the following, which avoids generating the extra multisets:







Any suggestions for a better approach?

David %^>

From: David Bevan
Sent: 01 October 2009 18:57
To: mathgroup at
Subject: [mg103681] generating submultisets with repeated elements

I'm new to Mathematica, so if I've missed something obvious, my apologies.

I want a function to generate a list of "submultisets" with up to k elements of a set s, allowing elements from s to be repeated.

The following works, but is very inefficient since each multiset is generated multiple times and then sorted and then repeats deleted:




I assumed there would be a suitable function in the Combinatorica package, but I can't see anything -- which would be a bit odd for a combinatorial package. What have I missed?

Do I need to write my own (perhaps by looking at how KSubsets is implemented) or is there some easy way of generating these multisets?


David %^>

  • Prev by Date: Re: White Noise in Simulation
  • Next by Date: Re: How to store data files in packages
  • Previous by thread: generating submultisets with repeated elements
  • Next by thread: Re: Re: generating submultisets with repeated elements