[racket] Pattern patching and structures

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Wed Nov 16 00:41:35 EST 2011

On 2011-11-16 13:11:33 +0800, José Lopes wrote:
> (define-struct brick
>   (shape cs size))
>
> and the following function
>
> (define (right brick)
>   (match brick
>     ((struct struct:brick (shape cs size))
>      (make-brick shape (xy (- (x size) 1) (y size)) size))))

The function argument binding "brick" is capturing the "brick"
identifier in the match pattern. If you rename the argument and use
"brick" instead of "struct:brick" here it should work.

Cheers,
Asumu


Posted on the users mailing list.