Take a look at combinatorics . It does what you need:
; all the unique ways of taking n different elements from items (clojure.math.combinatorics/combinations [1 2 3] 2) ;;=> ((1 2) (1 3) (2 3))
If he complains because you are using a set instead of a vector, just convert it to a vector with vec before calling combinations .
source share