3
我有一個循環:爲什麼此循環打印上次迭代的值?
(defun echo-lines()
(loop while
(let ((line (read-line)))
(if (equal line "done")
nil
(print line)))))
我預計他們結束行之後呼應了用戶的輸入,除非他們鍵入「完成」,在這種情況下,它停止。相反,它首次迴響了一條空白線,之後,它迴應了之前的一條輸入。 實施例:
* (echo-lines)
Hello, loop.
This is my second line.
"Hello, loop."
This is my third.
"This is my second line."
I'm almost done.
"This is my third."
done
"I'm almost done."
NIL
預期:
* (echo lines)
Hello, loop.
"Hello, loop."
done
NIL
這清楚地回答了我的問題,並提供了正確的解決方案。謝謝! =] – derekv