summaryrefslogtreecommitdiff
path: root/lib/std/slput.myr
blob: 88dc87594985a598acfaaabe91f0be4789f2c36b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use "types.use"
use "alloc.use"
use "die.use"

pkg std =
	generic slput	: (sl : @a[:], idx : size, elt : @a	-> @a[:])
;;

generic slput = {sl, idx, elt
	var i
	var len

	len = sl.len
	sl = slgrow(sl, sl.len + 1)
	for i = len - 1; i >= idx; i--
		sl[i + 1] = sl[i]
	;;
	sl[idx] = elt
	-> sl
}