Adam Röhr
Adam Röhr

Reputation: 41

Accept number or character

I know I can use (every #'digit-char-p str) to check if every character is an digit or (every #'alpha-char-p str) if it is a character. The problem is that I want to accept if the word contains letters or number but not symbols like +. Hello1 should return true but not Hello1-. Anyone knows how to do that?

Upvotes: 0

Views: 57

Answers (1)

user5920214
user5920214

Reputation:

every's first argument is a function (in fact a function designator): you can put any function you want there. In this case, as mentioned in a comment, there's a function defined by the language which does what you want, but if there wasn't you could write one:

(every (lambda (c) (or (digit-char-p c) (alpha-char-p c))) ...)

or (every (lambda (c) (and (explodablep c) (green c))) ...). Or anything you want.

Upvotes: 1

Related Questions