The Challenge:
To emulate the behaviour of the Express Tools' acet-list-group-by-assoc function, (however the list should be in the correct order, unlike that function...). The function needn't accomodate for dotted pairs.
Example:
(setq lst '((1 123 234) (2 234 345) (3 345 456) (2 456 567) (3 567 678)))
==> ((1 123 234) (2 234 345) (3 345 456) (2 456 567) (3 567 678))
(reverse (acet-list-group-by-assoc lst))
==> ((1 123 234) (2 234 345 456 567) (3 345 456 567 678))
I'll kick us off, as an example:
(defun _GroupByAssoc ( lst / rtn a )
(setq rtn (list (car lst)))
(while (setq lst (cdr lst))
(setq rtn
(if (setq a (assoc (caar lst) rtn))
(subst (cons (car a) (append (cdr a) (cdar lst))) a rtn)
(cons (car lst) rtn))))
(reverse rtn))
Enjoy,
Lee