возможно ли в CL создать безымянную(лямбда) рекурсивную функцию?
Так безымянную или лямбду? ;) См. alexandria:named-lambda
Да. Есть такая вещь: анафорическая лямбда.
(defmacro alambda (params &body body)
`(labels ((self ,params ,@body))
#'self))
http://www.xach.com/naggum/articles/3219426877120035@naggum.net.html:
> Has anyone ever thought it would be nice to recurse an anonymous lambda?
(defun jestcall (function &rest arg)
(apply function function args)) Where you would funcall a function that would funcall itself by name to
make a recursive call, you jestcall a function that jestcalls its first
argument to make a recursive call.
А к чему это? Если серьёзно, labels всё решает, и не фиг извращаться)
Скажем, для факториала:
(defun jestcall (function &rest args)
(apply function function args))(jestcall
(lambda (f n)
(if (zerop n)
1
(* n (jestcall f (1- n)))))
5)Ещё, jestcall — это «грязный» вариант первой же функции в этой статье про комбинаторы неподвижной точки:
http://okmij.org/ftp/Computation/fixed-point-combinators.html.