zl程序教程

您现在的位置是:首页 >  其它

当前栏目

format

format
2023-09-14 08:58:45 时间

format

;;; ~:fall(nil) ~;pass(其他)
> (format t "~:[fall~;pass~] ... ~A~%" t "hello")
pass ... hello
NIL
> (format t "~:[fall~;pass~] ... ~A~%" nil "hello")
fall ... hello

格式化指令可以接受参数。 ~F

> (format nil "~4,2,0,'*,' F" 3.14123)
"3.14"

> (format nil "~,2F" 3.14123)
"3.14"
> (format nil "~,3F" 3.14123)
"3.141"

遍历表中的数据

~^ 表内没有剩余元素时,立即停止迭代

(setf a '(a b c))
(format t "~{~A~^, ~}" a) ;A, B, C

输出char

(format t "~c~%" #\a) ; a
(format t "~@c~%" #\a) ; #\a