How does append work in Common Lisp?
I just started learning Lisp and I don't seem to understand the following pi开发者_StackOverflowece of code:
(setf y (loop for x in y
for z = (something)
unless (condition for z)
append z))
Where is z appended?
It is appended to an unnamed list to be returned when the loop terminates. As first approximation, you may think of it as a shorthand for
(loop ... append z into result finally (return result))
The append
here is a loop keyword; it's not related to the append
function, except for sharing the same name --- so it's the loop macro that decides how it works, instead of the append
function.
精彩评论