How to do a while loop in LISP

前端 未结 2 1711
忘了有多久
忘了有多久 2021-01-12 23:47

I cannot get a simple while loop to work in lisp!

(loop (while (row >= 0))
      setf(row (- row 1))
      (collect (findIndex row col))

2条回答
  •  忘掉有多难
    2021-01-13 00:17

    The correct form of the loop is the following:

    (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.

提交回复
热议问题