samba

Python array splice

Jan 25th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. # Array splice function similar to JavaScript's...
  2. def splice(ar, i, d, a*):
  3.     """ Inject values into an array, optionally dropping some at the insertion point
  4.     ar = the array to manipulate
  5.     i = where to inject
  6.     d = how many to drop at injection point
  7.     ... remaining args: what to inject
  8.     """
  9.     r = ar[0:i]
  10.     r.extend(a)
  11.     r.extend(ar[i + d:])
  12.     return r
Add Comment
Please, Sign In to add comment