> On Sep 24, 2017, at 9:32 PM, 'John Clements' via users-redirect 
> <us...@plt-scheme.org> wrote:
> 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! 

The definition of S-expression tends to be parameterized over the leafs 
(atoms). I’d be surprised if your particular version existed. [I assume you 
understand that you’re handing them a parser and that the use of this predicate 
may slow down the function (in terms of O-class).] — Matthias

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 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to