在Scheme中使用char-set

时间:2016-04-07 18:44:59

标签: list function scheme character punctuation

此函数必须在给定列表中找到!"#%&'()*,-./:;?@[\]_{}个字符。如果找到任何这些字符至少一次,则它必须返回true。但我无法找到适合此目标的预定义功能。

(define (is-symbol lst)
  (if (null? (car lst))
  #f
  (if (char-set:punctuation (car lst)) #t
           (is-symbol (cdr lst)))
  ))

(is-symbol '(#\A #\b #\t #\R #\f 3 5 4 7 8 9 #\A #\G #\w #\q $ & ?))

2 个答案:

答案 0 :(得分:0)

我相信你正在寻找char-punctuation?

(define (is-symbol? lst)
  (cond ((null? lst) #f)
        ((char-punctuation? (car lst)) #t)
        (else (is-symbol (cdr lst)))))

甚至更简单:

(define (is-symbol? lst)
  (ormap char-punctuation? lst))

答案 1 :(得分:0)

您正在使用 <dependency> <groupId>org.directwebremoting</groupId> <artifactId>dwr</artifactId> <version>3.rc1</version> <scope>system</scope> <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/dwr.jar</systemPath> </dependency> ,它看起来像SRFI-14。相应的成员资格谓词为char-set:punctuation