[plt-scheme] Match - naming the result of pat ...
--- Jens Axel Søgaard <jensaxel at soegaard.net> wrote:
> I have a feeling this have been asked before,
> and that the answer had something to do with
> (and ...), but ...
>
> Consider:
>
> > (match '(1 2 3 a 4 5)
> [((? number?) ... . more)
> more])
> (a 4 5)
>
> How do I get to the part matched by (? number?) ... ?
The '?' form allows you to put more patterns after the predicate, so
you could write the following to get the all-numeric prefix of the
list:
(match '(1 2 3 a 4 5)
[((? number? nums) ... . more)
nums])
Ryan
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com