Skip to content

Commit

Permalink
Avoid modifying a literal
Browse files Browse the repository at this point in the history
  • Loading branch information
olnw authored and vindarel committed Jan 20, 2024
1 parent c4e6ff0 commit 55cf1c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions iteration.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ infinitely. Here we show how to loop on a list forever.
We can build an infinite list by setting its last element to the list itself:

~~~lisp
(loop with list-a = '(1 2 3)
(loop with list-a = (list 1 2 3)
with infinite-list = (setf (cdr (last list-a)) list-a)
for item in infinite-list
repeat 8
collect item)
;; (1 2 3 1 2 3 1 2)
~~~

Illustration: `(last '(1 2 3))` is `(3)`, a list, or rather a cons cell, whose `car` is 3 and `cdr` is NIL. See the [data-structures chapter](data-structures.html) for a reminder. This is the representation of `(list 3)`:
Illustration: `(last (list 1 2 3))` is `(3)`, a list, or rather a cons cell, whose `car` is 3 and `cdr` is NIL. See the [data-structures chapter](data-structures.html) for a reminder. This is the representation of `(list 3)`:

~~~
[o|/]
Expand Down

0 comments on commit 55cf1c0

Please sign in to comment.