pattern matching with repeated named patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg39808] pattern matching with repeated named patterns
- From: Gara Kuta <garakuta at f2s.com>
- Date: Fri, 7 Mar 2003 03:42:36 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi
I have a list of data records which are all of the same type, for
example person:{name_Sting, sex:M|F, age_Integer, weight_?((1<#<500)&)}.
I want to access the different fields so I have given them names in the
pattern. I have a list of these records and I want to use pattern
matching to test the the whole list such as
{person:{name_Sting, sex:M|F, age_Integer, weight_?((1<#<500)&)}...}
but once you name the parts of the pattern, they have to be the same for
every record. I could leave the names out and use a pattern like
{{_Sting, M|F, _Integer, _?((1<#<500)&)}...}
which matches different records with the same structure but then I can't
access the field values by name. Is there any way I can do both at once?
Thanks
G