This is super cool indeed. Now I feel stupid.

On Wed, Dec 4, 2019 at 2:56 PM Matthew Butterick <[email protected]> wrote:

>
> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users <
> [email protected]> wrote:
>
> So it seems easy to match "*at least *N identical elements".
> But is there a method for matching "*no more than *N identical elements"?
>
>
> ?
>
>
> #lang racket
> (require rackunit)
>
> (define (super-cool? lst)
>   (match lst
>     [(and (list* _ ... a a _)
>           (not (list* _ ... a a a _))) #t]
>     [_ #f]))
>
> (check-true (super-cool? '(1 1 4)))
> (check-false (super-cool? '(1 1 1 4)))
>
> --
> 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/1734093C-0C39-4289-9747-41CAFB35851F%40mbtype.com
> <https://groups.google.com/d/msgid/racket-users/1734093C-0C39-4289-9747-41CAFB35851F%40mbtype.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADcuegu4s2bhEZNQ1fNt5JX-ENc91Ythaev7VezWk-ZY8Z2%2BcA%40mail.gmail.com.

Reply via email to