Re: Re: structs/records in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg41852] Re: [mg41784] Re: [mg41767] structs/records in mathematica
- From: Omega Consulting <info at omegaconsultinggroup.com>
- Date: Sat, 7 Jun 2003 00:08:41 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
At 06:31 AM 6/5/2003, Sseziwa Mukasa wrote: >I don't know about better or a standard but you can use the downvalues >of a head to simulate a struct eg. > >data[id]="this_or_that"; >data[value]="17.3; >data[compound[id]]="compound_id"; >data[compound[value]]=18.4; >data[compound[value]] > >Regards, > >Ssezi There's a nice feature of using this method. Mathematica has a pre-fix form where f@x is the same as f[x]. So you can write these as data@id="this_or_that"; data@value="17.3; data@compound@id="compound_id"; data@compound@value=18.4; data@compound@value This is just like you would do using structs, except that "." is replaced by "@". And unlike the rules, you don't need parenthesis. -------------------------------------------------------------- Omega Consulting "The final answer to your Mathematica needs" http://omegaconsultinggroup.com