You can use `in-dict` on an alist, and it will behave like the default
sequence behavior for hashes. Note that it assumes the elements are
cons pairs, not lists, so the values in your example will be '(1) and
'(20).

Sam
On Wed, Nov 21, 2018 at 11:55 AM Brian Adkins <lojicdot...@gmail.com> wrote:
>
> I thought it was possible to destructure a list in for, but I've been 
> searching/experimenting for a while without success. I noticed this example 
> in the docs:
>
> (for ([(i j) #hash(("a" . 1) ("b" . 20))])
>     (display (list i j)))
>
> So, I assumed I could do this:
>
> (for ([(i j) '(("a" 1) ("b" 20))])
>     (display (list i j)))
>
> But that doesn't work. I'm trying to avoid something as verbose as:
>
> (for ([(pair) '(("a" 1) ("b" 20))])
>      (match-let ([(list i j) pair])
>        (display (list i j))))
>
> Why do elements of a Hash provide 2 values to for, where a 2-tuple list does 
> not? Is there a more direct way to destructure a list in for?
>
> Thanks,
> Brian
>
> --
> 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.

-- 
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