How can I get all possible permutations of a list with Common Lisp?

后端 未结 3 1073
被撕碎了的回忆
被撕碎了的回忆 2021-02-08 11:01

I\'m trying to write a Common Lisp function that will give me all possible permutations of a list, using each element only once. For example, the list \'(1 2 3) will give the ou

3条回答
  •  长情又很酷
    2021-02-08 11:37

    Walk through your list, selecting each element in turn. That element will be the first element of your current permutation.

    Cons that element to all permutations of the remaining elements.

提交回复
热议问题