[racket] Combining iteration and match

From: Konrad Hinsen (konrad.hinsen at fastmail.net)
Date: Tue Sep 3 05:32:23 EDT 2013

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.

Posted on the users mailing list.