小编MRA*_*ing的帖子

如何使用子列表对列表进行排序(常见Lisp)

如何使用子列表对列表进行排序?

(setq list '((0) (1) (2) (0 1 5) (0 1 3) (0 1 5) (0 3 0) (0) (1) 
             (2 7 19) (0 0 3 0)))

; restricting the sort to only the first element:

(sort (copy-seq list) #'< :key #'car)

--> ((0) (0 1 5) (0 1 3) (0 1 5) (0 3 0) (0) (0 0 3 0) (1) (1) (2) (2 7 19))
Run Code Online (Sandbox Code Playgroud)

我正在寻找的输出是对子列表的所有元素排序:

--> ((0) (0) (0 0 3 0) (0 1 3) (0 1 …
Run Code Online (Sandbox Code Playgroud)

lisp sorting common-lisp

5
推荐指数
1
解决办法
7526
查看次数

标签 统计

common-lisp ×1

lisp ×1

sorting ×1