2017-11-11 58 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

非常感謝你解決了我的問題。 –

相關問題