• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: interesting discovery (trying to get record labels as strings)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interesting discovery (trying to get record labels as strings)


  • Subject: Re: interesting discovery (trying to get record labels as strings)
  • From: has <email@hidden>
  • Date: Tue, 4 Dec 2001 00:02:40 +0000

Neal A. Crocker wrote:

>you can shorten that to:
>
>{{+class usrf;:{"hello", "goodbye"}}} as string as record
>-- returns: {hello:"goodbye"}


Woahhh... nice one!

And after I picked myself up off the ground, I did:

======================================================================

on hackyFastConvertListToRecord(theList)
set newRec to {}
repeat with eachItem in theList
copy eachItem's item 2 to x
set newRec to newRec & ({{[LEFT-DOUBLE-CHEVRON]class
[NO-BREAK]usrf[RIGHT-DOUBLE-CHEVRON]:{(eachItem's item 1) as string,
[NO-BREAK]x}}} as string as record)
end repeat
newRec
end hackyFastConvertListToRecord

hackyConvertListToRecord({{"a", 1}, {"Bob", "hi"}, {22, false}, {"d",
[NO-BREAK]{a:1, b:2}}})
--> {a:1, |Bob|:"hi", |22|:false, d:{a:1, b:2}}

======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]

The above's not very efficient on big lists (due to the large
concatenations), but that could be improved (by processing the list items
in smaller batches and doing one big concat at the end). But aside from
that, it leaves the equivalent code in hashLib's convertListToRecord()
standing at the starting gate with a really dumb expression on its face.
Damn.

I might see if I can work this into hashLib's convertListToRecord()... It'd
need to automatically verify that the double coercion works OK on the host
machine (in case Chris N sneaks a patch in while I'm not looking;).
Depending on the results of that test, it would then use either this method
or the existing (slower but dependable) one to do the conversion.

has (standing at the starting gate with a really dumb expression on its face)


  • Prev by Date: Re: Path to app ...
  • Next by Date: Re: interesting discovery (trying to get record labels as strings)
  • Previous by thread: Re: interesting discovery (trying to get record labels as strings)
  • Next by thread: Re: interesting discovery (trying to get record labels as strings)
  • Index(es):
    • Date
    • Thread