[plt-scheme] match.ss epsilon

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Thu Jul 17 22:41:33 EDT 2003

With "match.ss", is there a way to optionally match a subpattern,
without consuming if there is no match?

I couldn't find syntax like "optional" or, better yet, "empty":

    (match '(b c) (((optional 'a) 'b 'c) #t))  =>  #t

    (match '(b c) (((or 'a empty) 'b 'c) #t))  =>  #t

Nor, I suppose, an upper-bound extension of the multiplicity syntax:

    (match '(b c) (('a ..0..1 'b 'c) #t))  =>  #t

The answer must be staring me in the face...

(Of course the above example can be done using two match clauses, but I
want to avoid combinatoric explosion of subpatterns in hairier cases.)

-- 
                                             http://www.neilvandyke.org/


Posted on the users mailing list.