有没有一种方法可以像使用macrolet的词汇闭包那样做?我要做的是使下面的宏成为本地递归帮助器,它对每个组合调用函数,而不是像现在在repl结果中调用宏那样生成一个列表:
  
  CL-USER> (combinations nil '(1 2 3) '(4 5 6))
((1 4) (1 5) (1 6) (2 4) (2 5) (2 6) (3 4) (3 5) (3 6))
  
   我想要的是一个宏,它接受一个函数和任意数量的列表,并在嵌套循环中对每个组合调用该函数。我对Lisp还很陌生,这是我写的第一个宏,它超越了“nif”克隆之类的东西,所以任何建议都会受到赞赏。
  
  
   我曾试图将宏转换为宏,在接受函数的宏中,(nReverse(list,item,@vars))行替换为“(func(list,item,@vars))”,但我得到错误的说法func是未定义的变量或函数。
  
  
   这是原始功能:
  
  (defmacro combinations (vars &rest lsts)
  (with-gensyms (item)
    `(loop for ,item in ,(car lsts) ,(if (null (cdr lsts)) 'collecting 'nconcing)
       ,(if (null (cdr lsts))
            `(nreverse (list ,item ,@vars))
            `(combinations (,item ,@vars) ,@(cdr lsts))))))
  
   这是我用macrolet尝试的,得到了未定义的函数“func”错误。
  
  (defmacro for-all-combonations (func &rest lst)
       (macrolet ((for-all (vars &rest lsts)
                    (with-gensyms (item)
                      `(loop for ,item in ,(car lsts) ,(if (null (cdr lsts)) 
                                                           'collecting 'nconcing)
                            ,(if (null (cdr lsts))
                                 `(func (nreverse (list ,item ,@vars)))
                                 `(for-all (,item ,@vars) ,@(cdr lsts)))))))
         (for-all nil lst)))