47 lines
917 B
Common Lisp
47 lines
917 B
Common Lisp
(defun map (fn ls)
|
|
(if (null ls)
|
|
()
|
|
(cons (funcall fn (first ls))
|
|
(map fn (rest ls))
|
|
)
|
|
)
|
|
)
|
|
|
|
(define-macro dlambda (&rest methods)
|
|
(cons
|
|
(quote lambda)
|
|
(cons
|
|
(quote (&rest arguments))
|
|
(list
|
|
(cons
|
|
(quote case)
|
|
(cons
|
|
(quote (first arguments))
|
|
(map
|
|
(lambda (method)
|
|
(cons
|
|
(first method)
|
|
(list
|
|
(cons
|
|
(quote apply)
|
|
(cons
|
|
(cons
|
|
(quote lambda)
|
|
(rest method)
|
|
)
|
|
(list (quote (rest arguments)))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
methods
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|