Function: LREC

Documentation

simplifies building a recursive functions over lists and finally returns evaluation of base. rec has to be a fun with 2 args. (lambda (value cont) ...), where value is the car of the list and cont is a function used to continue recursion

Source

(defun lrec (rec &optional base)
  "simplifies building a recursive functions over lists and finally returns
   evaluation of base.

   rec has to be a fun with 2 args.
     (lambda (value cont) ...),
     where value is the car of the list
     and cont is a function used to continue recursion"
  (labels ((self (lst)
	     (if (null lst)
		 (if (functionp base)
		     (funcall base)
		     base)
		 (funcall rec (car lst)
			  (lambda ()
			    (self (cdr lst)))))))
    #'self))
Source Context