Logo

Programming-Idioms

History of Idiom 44 > diff from v21 to v22

Edit summary for version 22 by :
Comment format

Version 21

2015-11-03, 22:19:51

Version 22

2015-11-30, 12:37:28

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