more coerce list to rec
more coerce list to rec
- Subject: more coerce list to rec
- From: Patrick Wynne <email@hidden>
- Date: Tue, 5 Dec 2000 13:07:03 -0800 (PST)
A while ago, I asked for a way to coerce a list to a record and
received the following script in reply:
set aList to {"firstname", "Robert", "lastname", "Robertson"}
set aRec to {}
repeat with i from 1 to ((number of items in aList) / 2)
set l to item (i * 2 - 1) of aList
set v to item (i * 2) of aList
set bRec to run script ("set bRec to {" & l & ":\"" & v & "\"}")
set aRec to aRec & bRec
end repeat
Now, I'm trying to make it recursive so that if the list contains a
list, it is handled properly. By way of example:
{"firstname", "Robert", "lastname", "Robertson", "info", {"bday",
"10/24/67", "hair", "brown", "eyes", "green"}}
becomes
{firstname:"Robert", lastname:"Robertson", info:{bday:"10/24/67",
hair:"brown", eyes:"green"}}
My script skills don't seem to be up to the task, however. Any
suggestions?
Thanks,
Patrick Wynne
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/