2017-11-11 56 views
-1

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

(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 
+0

为什么有关'lisp'标记的'scheme'的问题? –

+0

您是否验证了绑定到'x'的字符串? –

+0

对不起,我还应该删除common-lisp标签。我有点困惑。 –

回答

5

您需要设置正确的测试功能

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

或者equal应该正常工作。

关于Common Lisp的一些信息predicates

+0

非常感谢你解决了我的问题。 –

相关问题