transcendental-lisp/lisp/dlambda.lisp

53 lines
1.1 KiB
Common Lisp

(defun mapcar (fn ls)
(if (null ls)
()
(cons
(funcall fn (first ls))
(mapcar fn (rest ls))
)
)
)
(define-macro dlambda (&rest methods)
(cons
(quote lambda)
(cons
(quote (&rest arguments))
(list
(cons
(quote case)
(cons
(quote (first arguments))
(mapcar
(lambda (method)
(cons
(first method)
(list
(cons
(quote apply)
(cons
(cons
(quote lambda)
(rest method)
)
(list
(if (equal t (car method))
(quote arguments)
(quote (rest arguments))
)
)
)
)
)
)
)
methods
)
)
)
)
)
)
)