Re: Best practices for creating and comparing lists of text?
Re: Best practices for creating and comparing lists of text?
- Subject: Re: Best practices for creating and comparing lists of text?
- From: has <email@hidden>
- Date: Sun, 18 Dec 2005 13:31:26 +0000
Martin Orpen wrote:
> > For example, here's a simple solution in Python - no speed demon itself
>[snip]
>
>That's true :-)
Yes, though to be fair, while Python isn't the fastest of languages it's generally 'fast enough'. I've never found Python's speed a problem in general use, and any really intensive computation is easily pushed into C extensions and called from the main Python code. (e.g. There are already very fast 3rd-party extensions for tasks like heavy-duty number crunching, XML processing, 3D graphics.)
>Why do we need to bother with all these complicated solutions.
>
>How about a couple of awk one-liners that will do the job very quickly:
I dunno, awk may be easy if you already know it, otherwise it's all just line noise.[1] Emmanuel's regex solution was compact and elegant, and while a vanilla solution is more verbose and not particularly fast it's quite straightforward (standard-issue kludges aside), e.g.:
to parse_lists(txt)
script k -- list access speed kludge
property linesList : paragraphs of txt
property moduleNames : {}
property libNames : {}
end script
set text item delimiters to "="
repeat with lineRef in k's linesList
if lineRef's contents is not "" and lineRef does not start with "#" then
set end of k's moduleNames to text item 1 of lineRef
set end of k's libNames to text item -1 of lineRef
end if
end repeat
return {k's moduleNames, k's libNames}
end parse_lists
But, of course, YMMV, E&OE, etc.
has
[1] And if you are looking to learn, IMHO it'd be a much better investment to go with a modern scripting language like Perl or Python, rather than 25 year-old command-line tools that have no clue about modern technologies such as Unicode and XML.
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden