2017-03-06 11:00:18 -05:00
|
|
|
(load "functions.lisp")
|
2017-03-01 16:33:06 -05:00
|
|
|
|
2017-03-08 11:14:44 -05:00
|
|
|
;; A special function based on the dlambda macro presented in "Let Over Lambda" by Doug Hoyte.
|
|
|
|
|
2017-03-07 16:27:11 -05:00
|
|
|
(let
|
|
|
|
((add-method-clause
|
|
|
|
(lambda (method)
|
|
|
|
(cons (first method)
|
|
|
|
(list
|
|
|
|
(cons 'apply
|
|
|
|
(cons (cons 'lambda (rest method))
|
|
|
|
(list
|
|
|
|
(if (equal t (car method))
|
|
|
|
'arguments
|
|
|
|
'(rest arguments))))))))))
|
|
|
|
|
|
|
|
(define-special dlambda (&rest methods)
|
|
|
|
(cons 'lambda
|
|
|
|
(cons '(&rest arguments)
|
|
|
|
(list
|
|
|
|
(cons 'case
|
|
|
|
(cons '(first arguments)
|
|
|
|
(mapcar add-method-clause methods))))))))
|