On Tue, Jul 11, 2017 at 12:16 AM, Nadeem Abdul Hamid <nad...@acm.org> wrote:
> I'm looking for a general solution. Basically, I thought binding multiple
> id's would have achieved what this does:
>
>> (for/list ([t '((1 2 3) (4 5 6) (7 8 9) (a b c))])
>     (match-define (list x y z) t)
>     (list x z))
> '((1 3) (4 6) (7 9) (a c))
>

As far as I know, there's nothing built-in that does this, but it's
not hard to build:

(define (in-tuples xs)
  (make-do-sequence
   (λ ()
     (values
      (λ (pos)
        (apply values (car pos)))
      cdr
      xs
      (λ (pos)
        (not (null? pos)))
      #f
      #f))))

(for/list ([(x y z) (in-tuples '((1 2 3) (4 5 6) (7 8 9) (a b c)))])
  (list x z))

;; => '((1 3) (4 6) (7 9) (a c))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to