rafeesyed 发表于 2022-7-6 06:21:53

在列表中搜索字符串

大家好,
 
 
我想用lisp搜索列表中的字符串,任何人都可以帮我。
 
ex(setq a(列表“1”“2”“3”))
现在我想在列表中搜索“2”。
 
非常感谢。

rafeesyed 发表于 2022-7-6 06:43:55

只需将列表和搜索字符串传递给函数
 
前任:
 
(定义c:测试(/a是)
(setq a(列表“1”“2”“3”))
(setq yes(搜索字符串a“2”))
(如果(=是t)
(提示“找到”)
(提示“未找到”)
)
)
 
 
 
(defun searchstring(searchlist search/sealen sea anwser str)
(setq sealen(长度搜索列表))
(setq sea 0)
(setq anwser nil)
(虽然(
(setq str(第n个sea搜索列表))
(if(=(strcase search)(strcase str))
(程序
(setq anwser t)
)
)
(如果(=anwser t)
(setq sealen)
)
(setq海(+1海))
)
anwser公司
)

Tharwat 发表于 2022-7-6 06:50:26

如果在具有成员函数的列表中找到某个成员,则可以检查该成员。
 
例如
 

(setq a (list "1" "2" "3"))
(member "2" a)

SLW210 发表于 2022-7-6 07:00:32

请阅读代码发布指南并编辑您的帖子,将代码包含在代码标签中。

rafeesyed 发表于 2022-7-6 07:14:48

谢谢你的回复。

Tharwat 发表于 2022-7-6 07:30:47

 
不客气。
页: [1]
查看完整版本: 在列表中搜索字符串