Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 如何在递归置换函数中逐个返回置换列表元素?_List_Lisp_Common Lisp_Permutation - Fatal编程技术网

List 如何在递归置换函数中逐个返回置换列表元素?

List 如何在递归置换函数中逐个返回置换列表元素?,list,lisp,common-lisp,permutation,List,Lisp,Common Lisp,Permutation,我正在尝试写一个解码器,它使用26个英文字母。但是从26岁开始!计算起来太多了,我的置换函数无法返回整个列表,所以我想逐个返回这些元素以分别计算它们。如果有人帮我,那就太棒了。下面是排列函数 (defun permutations (coll) (if (not (cdr coll)) (list (first coll)) (loop for el in coll nconc (mapcar #'(lambda (combos)

我正在尝试写一个解码器,它使用26个英文字母。但是从26岁开始!计算起来太多了,我的置换函数无法返回整个列表,所以我想逐个返回这些元素以分别计算它们。如果有人帮我,那就太棒了。下面是排列函数

(defun permutations (coll)
    (if (not (cdr coll))
        (list (first coll))
        (loop for el in coll nconc
            (mapcar #'(lambda (combos) 
                (cons el combos))    
                (permutations (remove el coll)))

        )
    )
)

你可以使用亚历山大图书馆的地图排列。

我不能使用任何图书馆。还有其他选择吗?是的,您可以从库中复制函数。它是开源的。似乎您不需要更复杂的代码路径,因此可以对其进行删减。