如何从字符串创建关键字符号? [英] How does one create a keyword symbol from a string?
本文介绍了如何从字符串创建关键字符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从字符串中制作符号非常简单:
Making a symbol from a string is quite simple:
(intern "test") => test
我正在努力为plist创建关键字符号。寻找类似的东西:
I'm struggling to create keyword symbols for a plist. Looking for something like:
(XXXX "test") => :test
请注意(实习生:test)
不会产生 keyword 符号,而是产生一个包含冒号的符号(例如 |:test |
)。
Note that (intern ":test")
does not produce a keyword symbol but rather a symbol containing a colon (e.g. |:test|
).
如何在Common Lisp中正确生成关键字符号?谢谢!
How can one correctly generate keyword symbols in Common Lisp? Thanks!
推荐答案
关键字是普通符号,除了它们位于KEYWORD包内外:
Keywords are normal symbols except that they live inside the KEYWORD package:
? (defvar x (intern "NEWKW" "KEYWORD"))
X
? x
:NEWKW
? (keywordp x)
T
另请参见此处。
这篇关于如何从字符串创建关键字符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文