Flattening a list
Flattening a list
- Subject: Flattening a list
- From: Michelle Steiner <email@hidden>
- Date: Sat, 15 May 2004 18:21:45 -0700
Usually, when concatenating items to the end of a list, it's better to
use copy rather than set. However, when trying to flatten a list, you
have to use set.
set variable to "zzz"
set a to {{1, "z", 3}, {variable, "b", "c"}, {5, "text", variable}}
set b to {}
repeat with i from 1 to count of a
copy item i of a to end of b
end repeat
b
--> {{1, "z", 3}, {"zzz", "b", "c"}, {5, "text", "zzz"}}
set variable to "zzz"
set a to {{1, "z", 3}, {variable, "b", "c"}, {5, "text", variable}}
set b to {}
repeat with i from 1 to count of a
set b to b & item i of a
end repeat
b
--> {1, "z", 3, "zzz", "b", "c", 5, "text", "zzz"}
Is there a better way to flatten a list than looping like this?
-- Michelle
--
If you're not going somewhere, you're not getting anywhere.
_______________________________________________
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.