Plaster
New
List
Login
common-lisp
default
phoe
2022.01.21 12:41:24
(defun most-specific-type-specifiers (value type-specifiers) (let ((result (remove-if-not (alexandria:curry #'typep value) type-specifiers))) (loop with copy = (copy-list result) for a in copy do (loop for b in copy when (and (subtypep a b) (not (subtypep b a))) do (alexandria:removef result b)) finally (return result)))) CL-USER> (most-specific-type-specifiers 42 '(t cons real number integer (integer 0 42) (integer 42 43) (eql 42) (integer 42 42) rational)) ((EQL 42) (INTEGER 42 42))
Raw
Annotate
Repaste