I feel stupid too!

I like the trick of using list* to match _ on any number of trailing 
elements. The grammar given in the docs doesn't seem to include it; I'm 
curious by what rule is it "allowed" as a pattern?

On Wednesday, December 4, 2019 at 5:02:48 PM UTC-6, Sorawee Porncharoenwase 
wrote:
>
> This is super cool indeed. Now I feel stupid.
>
> On Wed, Dec 4, 2019 at 2:56 PM Matthew Butterick <[email protected] 
> <javascript:>> wrote:
>
>>
>> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users <
>> [email protected] <javascript:>> 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] <javascript:>.
>> 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/bde135bd-a69a-4c8d-8093-dbea6c9c93b9%40googlegroups.com.

Reply via email to