Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,13 @@
(defgeneric kar (kons)
(:documentation "Return the kar of a kons."))
(defgeneric kdr (kons)
(:documentation "Return the kdr of a kons."))
(defun konsp (object &aux (args (list object)))
"True if there are applicable methods for kar and kdr on object."
(not (or (endp (compute-applicable-methods #'kar args))
(endp (compute-applicable-methods #'kdr args)))))
(deftype kons ()
'(satisfies konsp))

View file

@ -0,0 +1,10 @@
(defmethod kar ((cons cons))
(car cons))
(defmethod kdr ((cons cons))
(cdr cons))
(konsp (cons 1 2)) ; => t
(typep (cons 1 2) 'kons) ; => t
(kar (cons 1 2)) ; => 1
(kdr (cons 1 2)) ; => 2

View file

@ -0,0 +1,11 @@
(defmethod kar ((n integer))
1)
(defmethod kdr ((n integer))
(if (zerop n) nil
(1- n)))
(konsp 45) ; => t
(typep 45 'kons) ; => t
(kar 45) ; => 1
(kdr 45) ; => 44