I was confusing about the difference between
case. In the document， it mentions that
match supports general pattern matching.
> (define (m x) (match x [(list a b c) #:when (= 6 (+ a b c)) 'sum-is-six] [(list a b c) 'sum-is-not-six])) > (m '(1 2 3)) 'sum-is-six > (m '(2 3 4)) 'sum-is-not-six
For this example, I thought I could rewrite it using
case expression. But seems it's quite complicated. I have to get the length of the input
x, and maybe a lambda function to get the sum of the elements of
x and compare it with
So I guess we prefer
match when doing pattern matching. Is it true? Any difference other than that?