Logo

Programming-Idioms

History of Idiom 44 > diff from v1 to v2

Edit summary for version 2 by :

Version 1

2015-05-06, 21:04:50

Version 2

2015-07-31, 19:53:24

Idiom #44 Insert element in list

Insert element x at position i in list s. Further elements must be shifted to the right.

Idiom #44 Insert element in list

Insert element x at position i in list s. Further elements must be shifted to the right.

Code
splice(@s, $i, 1, $x)
Comments bubble
The 0 tells splice we're replacing zero elements with $x at position $i--resulting in an insertion, rather than replacement.