Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Building an Associate List from a string

From: andrew:martin:colenso:school at: 24-Dec-2003 22:42

Tim wrote:
> I would like to employ a strategy that converts any value to the best
guess for a rebol datatype. IOWS, "54"[string!] would become 54[integer!]
> It occurs to me that a brute-force method would be to process via a
nested attempt[any[]] loop.
> Any more "elegant" ideas?
Rebol [] test: "age^-54^-name^-Tim Johnson^-occuptation^-coder^-Salary^-USD$100000.00" probe parse/all test [ some [ copy Word to tab skip (probe Word: to word! Word) [ copy Value integer^ (Value: to integer! Value) | copy Value money^ (Value: to money! Value) | copy Value [to tab | to end] ] (probe Value) [tab | end] ] end ] halt You'll need my %Patterns.r script to get values for integer^ and money^ (there's other patterns there as well). You need to put the above into a function and make 'Word and 'Value into local words and take out 'probe-s. I hope that helps! Andrew J Martin Attendance Officer Speaking in tongues and performing miracles Colenso High School Arnold Street, Napier. Tel: 64-6-8310180 ext 826 Fax: 64-6-8336759 http://colenso.net/scripts/Wiki.r?AJM http://www.colenso.school.nz/ DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally liable) for materials distributed to or acquired from user e-mail accounts. You can report any misuse of an e-mail account to our ICT Manager and the complaint will be investigated. (Misuse can come in many forms, but can be viewed as any material sent/received that indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate language and/or other issues described in our Acceptable Use Policy.) All outgoing messages are certified virus-free by McAfee GroupShield Exchange 5.10.285.0 Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]