[racket] Combining iteration and match

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Tue Sep 3 10:25:27 EDT 2013

I am fond of match-define too. The name is a little long, so I use this to
get shorter names:

(define-syntax defm (make-rename-transformer #'match-define))

(for/list ([a+b some-sequence])
    (defm (list a b) a+b)
    a)

Another construct with too long a name is define-values:

(define-syntax defv (make-rename-transformer #'define-values))

/Jens Axel

2013/9/3 Asumu Takikawa <asumu at ccs.neu.edu>

> On 2013-09-03 11:32:23 +0200, Konrad Hinsen wrote:
> >   (for/list ([(list a b) some-sequence])
> >     a)
>
> I usually use `match-define`:
>
>   (for/list ([a+b some-sequence])
>     (match-define (list a b) a+b)
>     a)
>
> Can be slightly longer than just `match` for simple cases, but doesn't
> cause rightward drift.
>
> Cheers,
> Asumu
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>



-- 
-- 
Jens Axel Søgaard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130903/c9785170/attachment.html>

Posted on the users mailing list.