字符串列表上的 lisp 成员函数

标签 lisp

我正在使用 LISP,想知道如何访问字符串列表中的成员。我已经尝试了成员函数,但一直得到 NIL。 谢谢

(setq phrase-list '( "What color is the sky?"  "It is Blue.")) ;list of strings

(write phrase-list)
(terpri)

(setq x(read-line)) ; I try to input What color is the sky?

(write(member x phrase-list)) ; I keep getting NIL

最佳答案

你需要设置正确的测试函数

(member x phrase-list :test #'string=)

或者 equal 也应该有效。

关于 Common Lisp 的一些信息 predicates

关于字符串列表上的 lisp 成员函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47233054/

相关文章:

list - 如何在 Common Lisp 中递归地将函数应用于所有子列表?

lisp - 使用 read-line 从 .txt 中读取,正在读取其他符号。记事本神器?

lisp - 让 Lisp "hello world"Web 应用程序运行的最简单方法

lisp - Lisp 中的空列表是从 cons 单元构建的吗?

javascript - 如何使用 Python 或 Lisp 删除无用的 JavaScript 代码

scheme - Racket 与 Scheme 有何不同?

inheritance - 检查对象的父类

list - 反转 LISP 中列表的前 n 个元素

lisp - 程序按预期工作,但错误消息仍然显示

emacs - Scheme 和 Elisp 函数求值的区别