检查字符串是否只是字母(没有符号和数字)lisp

Ben*_*ius 1 lisp string

我需要检查一个单词是否只是带字母示例"hfjel"返回true"df(f0"返回false

任何人都可以解释我的函数符号名称谢谢你的帮助

Mat*_*ard 5

有一个方便的标准功能alpha-char-p,可以满足您的要求.

CL-USER(1): (alpha-char-p #\a)
T
CL-USER(2): (alpha-char-p #\?)
T
CL-USER(3): (alpha-char-p #\?)
T
CL-USER(4): (alpha-char-p #\0)
NIL
CL-USER(5): (alpha-char-p #\.)
NIL
Run Code Online (Sandbox Code Playgroud)

您可以将它与every以下内容结合使用:

CL-USER(7): (every #'alpha-char-p "word")
T
CL-USER(8): (every #'alpha-char-p "nonword7")
NIL
CL-USER(9): (every #'alpha-char-p "non-alpha-word")
NIL
CL-USER(10): (every #'alpha-char-p "???")
T
Run Code Online (Sandbox Code Playgroud)