Next: Exercise 9. Up: Exercises Previous: Exercise 7.

Exercise 8.

Write a routine comb that when given a set of values and a non-negative integer returns a list of all combinations of the values of size . For example


> comb( {a,b,c,d}, 3 );

                    { {a,b,c}, {a,b,d}, {a,c,d}, {b,c,d} }

Modify your routine to work for lists which may contain duplicates, e.g.


> comb( [a,b,b,c], 2 );

                         [[a,b], [a,c], [b,b], [b,c]]


bondaren@thsun1.jinr.ru