lisp - 常见的 lisp 符号匹配

标签 lisp common-lisp

我有一个列表,格式如下:

((|* bank accounts| (|account 1| |account 2|))
 (|* airline miles| (|account 1| |account 2|))
 .....
 .....)

我不知道如何使用 assoc 来访问符号,因为它们的两边都用“|”框起来。

最佳答案

带引号的符号与任何其他符号一样对待,但保留符号的字符串大小写:

(assoc '|foo bar| '((|baz| . 1) (|foo bar| . 2))) => (|foo bar| . 2)

以下是更多示例(使用标准阅读器大小写设置):

(intern "foo bar") => |foo bar|

(intern "Foo") => |Foo|

(intern "FOO") => FOO

可以找到更长的答案on cliki .另请引用2.3.4 Symbols as TokensCommon Lisp Hyperspec .

关于lisp - 常见的 lisp 符号匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12420240/

相关文章:

debugging - "is not of type LIST"错误

emacs - 是否可以在 Lisp 中为函数名称设置别名?

common-lisp - (eval '(+ 1 2)) 和 (eval (+ 1 2)) 之间的区别?

emacs - (function) 在 Emacs 中有什么用途吗?

recursion - 计算在 Towers of hanoi Lisp 中移动的磁盘数量

macos - 在 Mac OS X 上安装 CLSQL

lisp - Lisp 中的 Flatten Nests 函数 - 需要帮助理解

macros - 宏: value is not of type LIST

lisp - Quicklisp:存档大小错误

lisp - 通过嵌套列表 LISP 递归