Plaster
New
List
Login
common-lisp
default
anonymous
2021.05.07 10:30:24
(let ((the-spec (lambda (x) (evenp x)))) (defun is-it-to-spec? (x) (funcall the-spec x)) (defun change-the-rules (new-spec) (setf the-spec new-spec))) (defun test (x) (typep x '(satisfies is-it-to-spec?))) ;; CL-USER> (test 42) ;; T ;; CL-USER> (test 41) ;; NIL ;; CL-USER> (change-the-rules (lambda (x) (oddp x))) ;; #<FUNCTION (LAMBDA (X)) {5403E68B}> ;; CL-USER> (test 42) ;; NIL ;; CL-USER> (test 41) ;; T ;; CL-USER>
Raw
Annotate
Repaste
Edit