On Wed, 11 Oct 2017 11:19:36 -0700, Alexis King
<lexi.lam...@gmail.com> wrote:

>> On Oct 11, 2017, at 11:10 AM, George Neuner <gneun...@comcast.net>
>> wrote:
>> 
>> My (maybe wrong) reading of the docs suggests that to match a hash
>> table, the table must be defined inline in the match clause.
>
>This isn’t really accurate. The hash-table match pattern matches a hash
>table itself, but it sounds like you want to do something else, wanting
>to use a separate, known dictionary as a lookup table for
>pattern-matching.

Hmm.  For completeness?   I'm having trouble imaging why you'd want to
match a literal hash table.  Or boxes.  The other options make more
sense.  Oh well.

>To do this, you probably want the `app` match pattern:
>
>    [(app (lambda (e) (dict-ref mydict e #f)) (? values val))
>     ....]
>
>That pattern will bind `val` to the result if it exists in the
>dictionary (and is non-#f). If you wanted this to be cleaner, you could
>wrap that pattern into a separate match expander.

I wish I'd been able to figure that out on my own.  Perhaps there
should be another example that shows catching result value(s) and
doing something with them.

Thank you!  
George

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