aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/goto.lua
blob: 421508ada63863c445cc706972abcd63daa6323b (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
do
	local a = 0
	::start::
	a = a + 1
	if a == 5 then
		goto done
	end
	goto start
	::done::
end
do
	for z = 1, 10 do
		for y = 1, 10 do
			for x = 1, 10 do
				if x ^ 2 + y ^ 2 == z ^ 2 then
					print('found a Pythagorean triple:', x, y, z)
					goto ok
				end
			end
		end
	end
	::ok::
end
do
	for z = 1, 10 do
		for y = 1, 10 do
			for x = 1, 10 do
				if x ^ 2 + y ^ 2 == z ^ 2 then
					print('found a Pythagorean triple:', x, y, z)
					print('now trying next z...')
					goto zcontinue
				end
			end
		end
		::zcontinue::
	end
end
do
	::redo::
	for x = 1, 10 do
		for y = 1, 10 do
			if not f(x, y) then
				goto continue
			end
			if not g(x, y) then
				goto skip
			end
			if not h(x, y) then
				goto redo
			end
			::continue::
		end
	end
	::skip::
end
do
	local _list_0 = t
	for _index_0 = 1, #_list_0 do
		local x = _list_0[_index_0]
		if x % 2 == 0 then
			print('list has even number')
			goto has
		end
	end
	print('list lacks even number')
	::has::
end