相关疑难解决方法(0)

Common Lisp:在列表中循环连续对的最佳方法是什么?

有时我需要遍历列表中的连续对.我现在这样做的方式是

(loop for x on lst while (not (null (cdr x)))
       (do something on (car x) and (cadr x)))
Run Code Online (Sandbox Code Playgroud)

我想知道是否有更好/内置的方法来做到这一点.

我需要这个的原因有时是我想要的,例如一些添加连续对的函数

(1 2 3 4 5) ----> (3 5 7 9)
Run Code Online (Sandbox Code Playgroud)

是否有像reduce这样的内置函数可以让我得到这个?

common-lisp

6
推荐指数
1
解决办法
2521
查看次数

标签 统计

common-lisp ×1