The first example can be called both nested function and partial evaluation. But the next example is more idiomatic. Both can be also called manual currying, although usually currying is understood as an automatic procedure. You can use currying in Lisp like this (one variant):
(defun curry (function &rest arguments)
(lambda (&rest more)
(multiple-value-call function
(values-list arguments) (values-list more))))
Speaking about the closure question: funcall
under let
is not a closure - a closure is a function definition inside let
. Actually, your first example is a closure, because you define a function inside another function, and each function introduces something akin to a let
binding.
Yet a more canonical example in your case would be:
(let ((z 10))
(defun close (x)
(* x z))
->CLOSE
(close 20)
->200
Here, z
is a variable captured in a closure.