shithub: mc

ref: ac713e58b7a309587fbbe4571c31f8f5683e2f67
dir: /libstd/slinsert.myr/

View raw version
use "types.use"
use "alloc.use"
use "fmt.use"

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

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

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