gpt4 book ai didi

lisp - 帮助理解 lisp 中的这一行

转载 作者:太空宇宙 更新时间:2023-11-03 18:41:23 24 4
gpt4 key购买 nike

(defun dump-db ()
(dolist (cd *db*)
(format t "~{~a:~10t~a~%~}~%" cd)))

dolist 使它遍历列表 *db* 的每个元素,变量 cd 对吗?

~a 意味着以更易读的形式打印它,但这两个让我感到困惑。

~{ ~} 这是否意味着 *db* 的每个元素都将被格式化?

~{~a:中的:是什么?

最佳答案

[The] iteration directive ~{ [...] tells FORMAT to iterate over the elements of a list or over the implicit list of the format arguments. 1

: 不是 format 指令,它只是逐字打印在每个元素之后:

> (format t "~{~a: ~}" '(foo bar))
FOO: BAR:

关于lisp - 帮助理解 lisp 中的这一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7583109/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com