On Jul 27, 2007, at 1:59 PM, RJay Hansen wrote:
> I want to create a list containing other lists but can't seem to
> figure out how to do it. When I create a new, empty list then try
> to add already-created lists, those lists lose their "listness",
> i.e. their contents just become items in the new list. For example:
>
> set thisList to {1, 2, 3}
> set thatList to {"a", "b", "c"}
> set bothLists to {}
> set bothLists to ((bothLists & thisList) & thatList)
>
> ---> {1, 2, 3, "a", "b", "c"}
>
> but I want to get:
>
> ---> {{1, 2, 3}, {"a", "b", "c"}}
>
> Can this be done?
Yes...and you were really close:
set thisList to {1, 2, 3}
set thatList to {"a", "b", "c"}
set bothLists to {}
set bothLists to ((bothLists & {thisList}) & {thatList})
--> {{1, 2, 3}, {"a", "b", "c"}}
The way it is can be startling, but it is consistent, and it allows
either sort of action.
--John
|