rafeesyed Posted July 10, 2013 Posted July 10, 2013 Hi all, I want search a string in list using lisp can any body help me. ex (setq a (list "1" "2" "3")) now i want to search "2" in a list. thank you Quote
rafeesyed Posted July 10, 2013 Author Posted July 10, 2013 just pass the list and search string to function ex: (defun c:test(/ a yes) (setq a (list "1" "2" "3")) (setq yes (searchstring a "2")) (if(= yes t) (prompt "found") (prompt "Not found") ) ) (defun searchstring(searchlist search / sealen sea anwser str) (setq sealen (length searchlist)) (setq sea 0) (setq anwser nil) (while( (setq str (nth sea searchlist)) (if(= (strcase search)(strcase str)) (progn (setq anwser t) ) ) (if(= anwser t) (setq sea sealen) ) (setq sea (+ 1 sea)) ) anwser ) Quote
Tharwat Posted July 10, 2013 Posted July 10, 2013 You can check if a member if found in a list with member function . e.g. (setq a (list "1" "2" "3")) (member "2" a) 1 Quote
SLW210 Posted July 10, 2013 Posted July 10, 2013 Please read the Code posting guidelines and edit your post to include the Code in Code Tags. Quote
Tharwat Posted July 11, 2013 Posted July 11, 2013 Thank you Tharwat for reply. You're very welcome . 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.