如何在 LISP 中执行 while 循环 [英] How to do a while loop in LISP
本文介绍了如何在 LISP 中执行 while 循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在 lisp 中使用简单的 while 循环!
I cannot get a simple while loop to work in lisp!
(loop (while (row >= 0))
setf(row (- row 1))
(collect (findIndex row col))
当 row 大于或等于 0 我想减少 row 并收集 findIndex 方法给出的结果.假设给出了 col.
while row is more or equal to 0 i want to decrement row and collect the result given by findIndex method. Suppose the col is given.
谢谢!!!
推荐答案
正确的循环形式如下:
(loop while (>= row 0)
do (setf row (- row 1)) ; or better: do (decf row)
collect (findIndex row col))
有关循环语法的详细说明,请参阅手册.
For a detailed description of the loop syntax, see the manual.
这篇关于如何在 LISP 中执行 while 循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文