admin管理员组文章数量:1335403
(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.
(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.
Share Improve this question asked Nov 20, 2024 at 1:03 JEPriceJEPrice 7131 gold badge7 silver badges10 bronze badges1 Answer
Reset to default 0Nothing 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.
本文标签: Common Lisp setting *printcircle* T causes list compressionStack Overflow
版权声明:本文标题:Common Lisp setting *print-circle* T causes list compression? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742387545a2465335.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论