Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 26 |
Nodes: | 6 (0 / 6) |
Uptime: | 59:24:55 |
Calls: | 633 |
Calls today: | 1 |
Files: | 1,188 |
D/L today: |
32 files (20,076K bytes) |
Messages: | 180,583 |
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.