resyntax
resyntax copied to clipboard
Unnecessary root-level `and` patterns
Encountered here:
#lang resyntax/test
test: "root-level and pattern can be removed when matching on a variable"
--------------------
#lang racket
(define (f xs)
(match xs
[(and foo (list x y ...))
(cons x (reverse foo))]))
--------------------
--------------------
#lang racket
(define (f xs)
(match xs
[(list x y ...)
(cons x (reverse xs))]))
--------------------
This applies whenever match is used on a variable and has an and pattern with an identifier as the outermost pattern in any branch.