0
(setq *print-circle* T)

;; then create some list with a large number of items, of which a bunch
;; of them repeat

If you then try to print the list in the repl, you will see a lot of unfamiliar text. Each of your items (in the beginning) will show a #1 or #2, etc, depending on the items location in your list. Where the list repeats itself, instead of the item printing out, you will have a #1# #2#, etc, depending on which item it the list it is a repeat of. This threw me, because I wasn't expecting it. I'm not sure if there is a way to mark a list so it won't do this behaviour when you print the object in the repl.

1 Answer 1

0

Nothing has been modified in the list, just the way it was represented was changed.

The way I worked around it is to defun a function to concatenate the list items in a single string, this forced an expansion of the list items.

(defun join-list-items( list )
  "joins all items in a list as one big string"
  (format nil "~{~a~}" list))

This isn't really a question, more of a warning that "here there be dragons" if you're unfamiliar with how SBCL handles the repl printing of a list that has duplicate items, if print-circle is set.

Sign up to request clarification or add additional context in comments.

1 Comment

No reason to downvote this guy. He's new to SBCL. It is all a mite overwhelming. He's just picking up on sharp notation and he's picking up on the repetion of items. JE: I might add that you'll find that crashes if you have a circular list. Have fun!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.