Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 52:39:52 |
Calls: | 583 |
Files: | 1,139 |
D/L today: |
179 files (27,921K bytes) |
Messages: | 111,617 |
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.