Now that I know how much faster ‘assert’ can be than ‘cast’, I’m eager to 
replace uses of ‘assert' all over the place.

Specifically, in my PL class, I’m hoping to get rid of uses of (cast … Sexp) 
that wind up principally in RHSes of match clauses.

In order to do this, I need a predicate of type (-> Any Boolean : Sexp). 

Well, strictly speaking, all I really need is the positive half, which I can 
construct like this:

(: sexp? (-> Any Boolean : #:+ Sexp))
(define (sexp? s)
  (or (number? s)
      (symbol? s)
      (string? s)
      (and (pair? s) (sexp? (car s)) (sexp? (cdr s)))
      (null? s)))

This works fine, and I can use it in an assert. 

Should I just drop this on my students, or is there an existing s-expression 
checking predicate that I can use?

Apologies if I’m just not looking hard enough! 


You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to