You can use slice () for this:
>> foo = [1,2,3,4,5,6] => [1, 2, 3, 4, 5, 6] >> bar = [10,20,30,40,50,60] => [10, 20, 30, 40, 50, 60] >> half = foo.length / 2 => 3 >> foobar = foo.slice(0, half) + bar.slice(half, foo.length) => [1, 2, 3, 40, 50, 60]
By the way, as far as I know, Python βlistsβ just efficiently implement dynamically growing arrays. The insert at the beginning is in O (n), the insert at the end is depreciated by O (1), random access is O (1).
Manuel Mar 29 '09 at 20:20 2009-03-29 20:20
source share