Common Lisp:如何显示一个点?

Rog*_*llo 1 common-lisp

我想用点(.)作为符号,像ab.

我发现我可以通过引用和转义点来实现.但是,当点显示在屏幕上时,它被垂直条包围:

'\.
=> |.|
Run Code Online (Sandbox Code Playgroud)

如何在没有垂直条的情况下显示点?

更新:谢谢你jkiiski,使用的format工作很棒.这就是我这样做的原因:对于我自己的教育,我编写了一个函数,将列表表示法中的列表转换为点表示法中的等效列表.感谢您的帮助,现在效果很好:

(defun list-notation-to-dot-notation (lst)
    (cond ((atom lst) lst)
          ((null (cdr lst)) (list (list-notation-to-dot-notation (car lst)) '\. 'NIL))
          (t (list (list-notation-to-dot-notation (car lst)) '\. (list-notation-to-dot-notation (cdr lst))))))

(defun list-2-dot (lst)
    (format t "~a" (list-notation-to-dot-notation lst)))

(list-2-dot '(a))
=> (A . NIL)

(list-2-dot '(a b))
=> (A . (B . NIL))

(list-2-dot '((a) b))
=> ((A . NIL) . (B . NIL))

(list-2-dot '(a (b) c))
=> (A . ((B . NIL) . (C . NIL)))

(list-2-dot '(a b (c)))
=> (A . (B . ((C . NIL) . NIL)))

(list-2-dot '((a) (b) (c)))
=> ((A . NIL) . ((B . NIL) . ((C . NIL) . NIL)))
Run Code Online (Sandbox Code Playgroud)

jki*_*ski 5

这将是一种更简洁的方式来实现相同的结果:

(defun print-dot-notation (list &optional (stream *standard-output*))
  (if (atom list)
      (format stream "~s" list)
      (format stream "(~a . ~a)"
              (print-dot-notation (car list) nil)
              (print-dot-notation (cdr list) nil))))

(print-dot-notation '(a (b) c))
; (A . ((B . NIL) . (C . NIL)))
Run Code Online (Sandbox Code Playgroud)

无需创建额外列表或使用点符号.