Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
13
Task/Abstract-type/Common-Lisp/abstract-type-1.lisp
Normal file
13
Task/Abstract-type/Common-Lisp/abstract-type-1.lisp
Normal 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))
|
||||
10
Task/Abstract-type/Common-Lisp/abstract-type-2.lisp
Normal file
10
Task/Abstract-type/Common-Lisp/abstract-type-2.lisp
Normal 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
|
||||
11
Task/Abstract-type/Common-Lisp/abstract-type-3.lisp
Normal file
11
Task/Abstract-type/Common-Lisp/abstract-type-3.lisp
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue