Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 25 |
Nodes: | 6 (0 / 6) |
Uptime: | 29:14:37 |
Calls: | 491 |
Files: | 1,078 |
Messages: | 67,190 |
I need a function which partitions a set according to
some equivalence relation.
Is this what you need?
(defun partition (set equivalence)
(loop for s = set then (set-difference s eqv-class :test equivalence)
while s
for eqv-class = (remove-if-not (lambda (x)
(funcall equivalence x (first s)))
s)
collect eqv-class))
CL-USER 57 > (partition '(aabs qweq rew er rtyrtyr s q w e foo bar)
(lambda (x y) (= (length (string x))
(length (string y)))))
((AABS QWEQ) (BAR FOO REW) (ER) (E W Q S) (RTYRTYR))
This is far from efficient, but should be a lot better than wading
through powersets.