I was wondering if anyone is aware of any Lisp code out there for the following problem:
Given X elements of data and Y group size, return all possible unique groupings of the elements for group size Y
(unique element combinations *not* element ordering i.e. (a b) is the same as (b a) for my purposes). So given X
(elements) of (a b c d) and a Y (group size) of 2 (2 elements per group) I want to get all possible combinations for a
2 element group: ((a b) (b c) (c d) (a c) (a d) (b d)). For a Y (group size) of 3 the data returned would be: ((a b c)
(a b d) (a c d) (b c d)). There are no restrictions on the number of elements or group size and the order of returned
groupings is not critical.
I am looking to see how others have solved this type of problem as the code I have written pretty much sucks (and I'm
finding it doesn't always work). Please email replies.
TIA,
Phil