the Holy Grail of AppleScript lists
the Holy Grail of AppleScript lists
- Subject: the Holy Grail of AppleScript lists
- From: Paul Skinner <email@hidden>
- Date: Wed, 19 Mar 2003 13:09:35 -0500
I may be fooling myself, but I seem to have found a way around the
limitation that AppleScript has with returning large lists as the
result of a single command.
I was testing 'do shell script' ascii sorts as an alternative to the
colossal quickSort. I resolved it down to...
set delim to return
set AppleScript's text item delimiters to delim
set l to {"3", "a", "C", "c", "B", 2, "A", 1}
set t to (do shell script ("echo '" & l as text) & "' | tr '" & delim &
"' '\n' | sort -f")
-->1
2
3
A
a
B
C
c
Nice.
Then to coerce the result back to a list I modified it to be...
set delim to return
set AppleScript's text item delimiters to delim
set l to {"3", "a", "C", "c", "B", 2, "A", 1}
set t to text items of (do shell script ("echo '" & l as text) & "' |
tr '" & delim & "' '\n' | sort -f")
-->{"1", "2", "3", "A", "a", "B", "C", "c"}
Very nice!
Here's where I got a shock. I wanted to test the speed so I upped the
size of the list...
set delim to return
set l to {"3", "a", "C", "c", "B", 2, "A", 1}
repeat 10 times
set l to l & l
end repeat
set AppleScript's text item delimiters to delim
set t to text items of (do shell script ("echo '" & l as text) & "' |
tr '" & delim & "' '\n' | sort -f")
-->list of 8291 items.
!!! WHAT!? how many? how the... That can't... DAMN! wow.
Why this is possible I can't say. I'm hoping Nigel or Chris will
comment on the underlying reason.
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.