(defpackage :find
(:use common-lisp)
(:shadow find))
(in-package :find)
(defgeneric find (collection query))
(defstruct range
(before 0 :type integer)
(after 0 :type integer))
(defclass a () ())
(defmethod find ((c a) (q integer)) q)
(defclass b () ())
(defmethod find ((c b) (q range)) q)
(defun main ()
(let ((a (make-instance 'a))
(b (make-instance 'b))
(r (make-range :before 1 :after 3)))
(print (find a 1))
(print (find b r))))
(main)
KGRlZnBhY2thZ2UgOmZpbmQKICAgKDp1c2UgY29tbW9uLWxpc3ApCiAgICg6c2hhZG93IGZpbmQpKQoKKGluLXBhY2thZ2UgOmZpbmQpCgooZGVmZ2VuZXJpYyBmaW5kIChjb2xsZWN0aW9uIHF1ZXJ5KSkKCihkZWZzdHJ1Y3QgcmFuZ2UKICAoYmVmb3JlIDAgOnR5cGUgaW50ZWdlcikKICAoYWZ0ZXIgIDAgOnR5cGUgaW50ZWdlcikpCgooZGVmY2xhc3MgYSAoKSAoKSkKCihkZWZtZXRob2QgZmluZCAoKGMgYSkgKHEgaW50ZWdlcikpIHEpCgooZGVmY2xhc3MgYiAoKSAoKSkKCihkZWZtZXRob2QgZmluZCAoKGMgYikgKHEgcmFuZ2UpKSBxKQoKKGRlZnVuIG1haW4gKCkKICAobGV0ICgoYSAobWFrZS1pbnN0YW5jZSAnYSkpCiAgICAgICAgKGIgKG1ha2UtaW5zdGFuY2UgJ2IpKQogICAgICAgIChyIChtYWtlLXJhbmdlIDpiZWZvcmUgMSA6YWZ0ZXIgMykpKQogICAgKHByaW50IChmaW5kIGEgMSkpCiAgICAocHJpbnQgKGZpbmQgYiByKSkpKQoKKG1haW4p