返回字符串中的第一个表或第一个原子
(read [string])
read 函数分析字符串,并将字符串中的第一个“词”转换为对应的数据类型并返回。
参数
string
字符串。string 参数不能在表或字符串外包含空格。
返回值
read 函数将其参数转换成相应的数据类型后返回。如果未指定参数,read 返回 nil。
如果字符串中包含由空格、换行符、制表符或括号等 LISP 分隔符分开的多个词,则只返回其中的第一个词。
示例
Command: (vl-prin1-to-string 'a)
"A"
Command: (read
"A")
A
(defun symbol-name (sym / f str tmp)
(setq tmp
"$sym.tmp") ;vl-filename-mktemp
(setq f (open tmp "w"))
(princ sym f)
(close f)
(setq f (open tmp
"r")
str (read-line f)
f (close f)
)
;(startapp "notepad" tmp)
str
)
Command: (read "\"Hi Y’all\"")
"Hi Y’all"
Command: (read "1.2300")
1.23
Command: (read "87 3.2")
87
明经通道 版权所有 未经许可 不得传播 |
评论 |