summaryrefslogtreecommitdiff
path: root/tetris/utility.prn
blob: 3a4b912c18d08786dba081fd000d76a631b7bac8 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@defun "add2" {
	"y2" store
	"x2" store
	"y1" store
	"x1" store
	x1 x2 +
	y1 y2 +
}

@defun "diff2" {
	"y2" store
	"x2" store
	"y1" store
	"x1" store
	x1 x2 -
	y1 y2 -
}

@defun "dup2" {
	"b" store
	"a" store
	a b a b
}

@defun "dup4" {
	"d" store
	"c" store
	"b" store
	"a" store
	a b c d a b c d
}

@defun "swap2" {
	"b2" store
	"b1" store
	"a2" store
	"a1" store
	b1 b2 a1 a2
}

@defun "replicate" { #args: value times
	dup 1 < if
		pop pop
	else
		1 - "t" store
		t 0 > while
			dup
			t 1 - "t" store
		t 0 > end
	end
}