> 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.

Reply via email to