[racket] Combining iteration and match

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Sep 3 08:27:08 EDT 2013

You want generic-bind:


On Tue, Sep 3, 2013 at 3:32 AM, Konrad Hinsen <konrad.hinsen at fastmail.net>wrote:

> Hi everyone,
> I find myself writing lots of expressions such as
>   (for/list ([temp some-sequence])
>     (match temp [(list a b) a]))
> where I iterate over a sequence and then destructure each element of
> the sequence using match, most often to pick some fields out of
> a struct. Is there a more compact way to do this? Ideally I'd like
> to write
>   (for/list ([(list a b) some-sequence])
>     a)
> I could probably hack together a suitable macro, but I wonder if there's
> already an idiomatic way to handle this situation.
> Konrad.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130903/a9afa4c4/attachment.html>

Posted on the users mailing list.