-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththesis-tables.mar
39 lines (36 loc) · 1.33 KB
/
thesis-tables.mar
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
import thesis-examples.mar
fun print_generate_table() {
println("Generate table:")
var random = random_number_generator()
for complexity in list(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500) do {
var term = static[Term]().generate(random.&, complexity)
print("{complexity} & {term} & {switch try term.eval() case ok(num) "{num}" case error "-"} \\\\ \\hline \n")
}
}
fun ops(left: Term, right: Term): Operands {
Operands { left = left.put_on_heap(), right = right.put_on_heap() }
}
fun print_mutate_table() {
var random = random_number_generator()
| -2 * 4 * -9 * -5 / (-6 * -2 * -9 / -5)
var term = Term.divide(ops(
Term.multiply(ops(
Term.multiply(ops(Term.number(0-2), Term.number(4))),
Term.multiply(ops(Term.number(0-9), Term.number(0-5))),
)),
Term.multiply(ops(
Term.multiply(ops(Term.number(0-6), Term.number(0-2))),
Term.divide(ops(Term.number(0-9), Term.number(0-5))),
))
))
println("Original term: {term}")
println("Mutate table:")
for temperature in list(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500) do {
var term = term.mutate(random.&, temperature)
print("{temperature} & {term} & {switch try term.eval() case ok(num) "{num}" case error "-"} \\\\ \\hline \n")
}
}
fun main() {
print_generate_table()
print_mutate_table()
}