• 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: Appending a list to a list and getting one list.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Appending a list to a list and getting one list.


  • Subject: Re: Appending a list to a list and getting one list.
  • From: Lachlan Deck <email@hidden>
  • Date: Tue, 14 May 2002 11:14:02 +1000

Hi there,

From: Paul Skinner <email@hidden>

set bigListRef to a reference to bigList
set numItems to 10000
set t to (time of (current date)) --Start timing operations.
repeat with n from 1 to numItems
copy n to the end of bigListRef
end repeat
set total to (time of (current date)) - t --End timing.
total --result: 1 second

--But...

set bigList to {}
set bigListRef to a reference to bigList
set numItems to 10000
set t to (time of (current date)) --Start timing operations.
repeat with n from 1 to numItems
set bigListRef to bigListRef & n --SuperSlowDowner!
end repeat
set total to (time of (current date)) - t --End timing.
total --result: 109 seconds

The example made me think that they are doing a similar thing
(concatenating) in the 10K iterations as they show prior to it. Not so.
If you want to concatenate a list to a list then you have to wait.
References aren't a bit of help.
Can anyone tell me how to append a list to a list and get just one
list?

With text lists under 4K text items combined I can...

set l to {"red", "orange", "yellow"}
set l2 to {"green", "blue", "indigo"}
set AppleScript's text item delimiters to "o#?o#?"--Sentinel high ascii
string
set l to every text item of ((l as text) & AppleScript's text item
delimiters & l2 as text)
-->{"red", "orange", "yellow", "green", "blue", "indigo"}

But I am hoping someone can tell me there's a better way.

on cat_lists(main_list, the_lists)
repeat with i from 1 to the number of items in the_lists
set this_list to item i of the_lists
repeat with j from 1 to the number of items in this_list
set the end of main_list to (item j of this_list)
end repeat
end repeat
return main_list
end cat_lists

set a to {"A", "big", "list"}
set b to {"red", "orange", "yellow"}
set c to {"green", "blue", "indigo"}

set a to cat_lists(a, {b, c})

Obviously the order you pass in the lists determines what order they'll come back as...

--
Paul Skinner

with regards,

--
Lachlan Deck
email@hidden
_______________________________________________
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.

  • Prev by Date: Re: Re: Parents/Child Scripts
  • Next by Date: Pdf Guide to scripting Canvas (from Deneba software)
  • Previous by thread: Re: Appending a list to a list and getting one list.
  • Next by thread: Re: Appending a list to a list and getting one list.
  • Index(es):
    • Date
    • Thread