所以功能:
(defun royal-we () (sublis '((i . we)) '(if I learn lisp I will be pleased)))SBCL中的输出以这种方式打印:
(IF WE LEARN LISP WE WILL BE PLEASED)然而,例子之一:
(sublis '((roses . violets) (red . blue)) '(roses are red))给出输出
(VIOLETS ARE BLUE)为什么SBCL在不同的行上打印列表的原子,不像其他发行版如Clisp?
So the function:
(defun royal-we () (sublis '((i . we)) '(if I learn lisp I will be pleased)))The output in SBCL is printed this way:
(IF WE LEARN LISP WE WILL BE PLEASED)Yet the example one:
(sublis '((roses . violets) (red . blue)) '(roses are red))gives the output
(VIOLETS ARE BLUE)Why is SBCL printing the atoms of the list on different lines, unlikeo other distributions like Clisp?
最满意答案
(if …)列表由漂亮的打印机处理,假设它(可能)是一个实际的Lisp形式。
CL-USER> (setf *print-pretty* nil) NIL CL-USER> '(if 1 2 3) (IF 1 2 3) CL-USER> (setf *print-pretty* t) T CL-USER> '(if 1 2 3) (IF 1 2 3)除此之外,您会发现,表单也会以类似方式缩进,并且某些loop符号将以新行开始。 还有一些其他的影响。
CL-USER> '(loop for thing in stuff with boo = 4 count mice) (LOOP FOR THING IN STUFF WITH BOO = 4 COUNT MICE) CL-USER> '(let 1 2 3) (LET 1 2 3) CL-USER> '(defun 1 nil 2 3) (DEFUN 1 () 2 3) CL-USER> (setf *print-pretty* nil) NIL CL-USER> '(defun 1 nil 2 3) (DEFUN 1 NIL 2 3)顺便说一句,相关的标准被发现... http://www.lispworks.com/documentation/lw60/CLHS/Body/22_b.htm ...如果你想要为你的目的重新编程它。
对于打印数据列表,我怀疑禁用漂亮打印或使用FORMAT可能就足够了。
例如,
(format t "~&~@(~{~a~^ ~}~)" '(violets are blue)) Violets are blueThe (if …) list is being handled by the pretty-printer under the assumption that it's (potentially) an actual Lisp form.
CL-USER> (setf *print-pretty* nil) NIL CL-USER> '(if 1 2 3) (IF 1 2 3) CL-USER> (setf *print-pretty* t) T CL-USER> '(if 1 2 3) (IF 1 2 3)You'll find that, among other things, let forms will also be indented similarly, and certain loop symbols will start new lines. There are a few other effects.
CL-USER> '(loop for thing in stuff with boo = 4 count mice) (LOOP FOR THING IN STUFF WITH BOO = 4 COUNT MICE) CL-USER> '(let 1 2 3) (LET 1 2 3) CL-USER> '(defun 1 nil 2 3) (DEFUN 1 () 2 3) CL-USER> (setf *print-pretty* nil) NIL CL-USER> '(defun 1 nil 2 3) (DEFUN 1 NIL 2 3)BTW, the relevant standards are found … http://www.lispworks.com/documentation/lw60/CLHS/Body/22_b.htm … if you were to, say, want to reprogram it for your purposes.
For just printing data lists, I'd suspect disabling pretty-printing or using FORMAT would probably suffice, though.
eg,
(format t "~&~@(~{~a~^ ~}~)" '(violets are blue)) Violets are blue更多推荐
发布评论