List of Lists

Again, please bear with me if the answer to this is obvious…

Is it possible to create a list of lists automatically? Something like this:


set the_big_list to {}
repeat with j from 1 to 6 by 3
	set the_list to {}
	repeat with i from j to (j + 2)
		set the_list to (the_list & i)
	end repeat
	set the_big_list to (the_big_list & the_list)
end repeat

This snippet produces {1,2,3,4,5,6}, because “&” merges the_list into the_big_list. I’d like to get {{1,2,3},{3,4,5}}, but I can’t figure out how. From reading the Language Guide, it seems to me that it can’t be done, because there’s no operator that joins lists like that. Am I wrong?

Thanks

Er, sorry for the goof! That should read “I’d like to get {{1,2,3},{4,5,6}}”, of course. I must be having a senior moment…

Thanks.

Replace that with this:

set end of the_big_list to the_list

You could also write it like this:

set the_big_list's end to the_list

Thanks, that’s exactly what I needed.

set x to {1, 2, 3}
set y to {4, 5, 6}
set z to x & y – {1, 2, 3, 4, 5, 6}
copy {x} & {y} to lstZ – {{1, 2, 3}, {4, 5, 6}}

copy {x} to lstZ
copy lstZ & {y} to lstZ – {{1, 2, 3}, {4, 5, 6}}

set firstThree to {1, 2, 3}
set lastThree to {4, 5, 6}

set theBigList to {firstThree, lastThree}