diff --git a/functions.lisp b/functions.lisp index d757a82466fd4ece06d3a317db6c79c7f08a234b..a04b7d026e1870a4da0c92c8dad68fb2a0d5a4d7 100644 --- a/functions.lisp +++ b/functions.lisp @@ -142,6 +142,16 @@ with and ARGUMENTS to FUNCTION." (declare (dynamic-extent more)) (multiple-value-call fn (values-list more) (values-list arguments))))) +(define-compiler-macro rcurry (function &rest arguments) + (let ((rcurries (make-gensym-list (length arguments) "RCURRY")) + (fun (gensym "FUN"))) + `(let ((,fun (ensure-function ,function)) + ,@(mapcar #'list rcurries arguments)) + (declare (optimize (speed 3) (safety 1))) + (lambda (&rest more) + (declare (dynamic-extent more)) + (multiple-value-call ,fun (values-list more) ,@rcurries))))) + (declaim (notinline curry rcurry)) (defmacro named-lambda (name lambda-list &body body)