summaryrefslogtreecommitdiff
path: root/libstd/slcp.myr
blob: 1035a294b7d50d658f285d3f44f4fe62a431554e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use "die.use"
use "types.use"

pkg std =
	generic slcp : (a : @a[:], b : @a[:] -> void)
;;

generic slcp = {a : @a[:], b : @a[:]
	var i
	var addr_a, addr_b

	assert(a.len == b.len, "arguments to slcp() must be of equal length")

	addr_a = a castto(@a#) castto(intptr)
	addr_b = b castto(@a#) castto(intptr)
	if addr_a <= addr_b
		for i = 0; i < a.len; i++
			a[i] = b[i]
		;;
	else
		for i = a.len; i > 0; i--
			a[i - 1] = b[i - 1]
		;;
	;;
		
}