Right... except that I completely misread your first example, which is
not at all the same as my example with `cons` patterns. Sorry about
that.

On Thu, Dec 31, 2020 at 2:06 PM Jon Zeppieri <[email protected]> wrote:
>
> On Wed, Dec 30, 2020 at 2:24 PM David Storrs <[email protected]> wrote:
> >
> > First off, is there a way to make ... in a pattern match non-greedily?  
> > i.e., match as *few* elements as possible instead of as many?
>
> As far as I know, no. However, if your first example is really
> illustrative of what you're trying to do, you could just use a `cons`
> pattern instead of a `list` pattern:
>
> (match (list '(a b c) '(d e c))
>   [(list (cons _ xs) (cons _ ys))
>    #:when (equal? xs ys)
>    'ok]
>   [else 'nope])
> => 'nope

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxw3Pywy_Hh%3D7H3CRKT2OfnqAksb3r2jwMrqvrNvDqdt7g%40mail.gmail.com.

Reply via email to