mappend function
maybe-print-unreadable-object macro
merge-error-candidates generic
+ merge-error-present-function generic
merge-lists function
sb-mop:method-specializers generic
once-only macro
cl:standard-object
merge-error-candidates
inconsistent-merge-error
+merge-error-present-function
+ inconsistent-merge-error
sb-mop:method-specializers
cl:standard-method
\subsection{Merging lists}
-\begin{describe}{cls}{inconsistent-merge-error (error) \&key :candidates}
+\begin{describe}{cls}
+ {inconsistent-merge-error (error) \&key :candidates :present}
\end{describe}
\begin{describe}{gf}{merge-error-candidates @<error> @> @<list>}
\end{describe}
+\begin{describe}{gf}{merge-error-present-function @<error> @> @<function>}
+\end{describe}
+
\begin{describe}{fun}
{merge-lists @<lists> \&key :pick (:test \#'eql) :present @> @<list>}
\end{describe}
(cdddr neigh-record) best-path)))))))
dead))
-(export '(inconsistent-merge-error merge-error-candidates))
+(export '(inconsistent-merge-error
+ merge-error-candidates merge-error-present-function))
(define-condition inconsistent-merge-error (error)
((candidates :initarg :candidates
- :reader merge-error-candidates))
+ :reader merge-error-candidates)
+ (present :initarg :present :initform #'identity
+ :reader merge-error-present-function))
(:documentation
"Reports an inconsistency in the arguments passed to `merge-lists'.")
(:report (lambda (condition stream)
(format stream "Merge inconsistency: failed to decide between ~
~{~#[~;~A~;~A and ~A~:;~
~@{~A, ~#[~;and ~A~]~}~]~}"
- (merge-error-candidates condition)))))
+ (mapcar (merge-error-present-function condition)
+ (merge-error-candidates condition))))))
(export 'merge-lists)
(defun merge-lists (lists &key pick (test #'eql) (present #'identity))
candidates))
(winner (cond ((null leasts)
(error 'inconsistent-merge-error
- :candidates (mapcar present candidates)))
+ :candidates candidates
+ :present present))
((null (cdr leasts))
(car leasts))
(pick