transcendental-lisp/lisp/dlambda.lisp

53 lines
1.1 KiB
Common Lisp
Raw Normal View History

2017-03-02 14:26:47 -05:00
(defun mapcar (fn ls)
(if (null ls)
()
2017-03-02 14:26:47 -05:00
(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))
2017-03-02 14:26:47 -05:00
(mapcar
(lambda (method)
(cons
(first method)
(list
(cons
(quote apply)
(cons
(cons
(quote lambda)
(rest method)
)
2017-03-02 14:26:47 -05:00
(list
(if (equal t (car method))
(quote arguments)
(quote (rest arguments))
)
)
)
)
)
)
)
methods
)
)
)
)
)
)
)