summaryrefslogtreecommitdiff
path: root/libstd/slput.myr
blob: c1a7d33ce4a2b129b088a23153ada8cb44595df0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use "types.use"
use "alloc.use"
use "die.use"
use "fmt.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
}