-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.lzr
83 lines (63 loc) · 1.18 KB
/
test.lzr
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using "random"
#jInclude "java.util.Stack"
stack = new Stack()
stack.push(8)
stack.push(9)
println(stack.pop())
func greet(name){
// println("Hello $name")
println("Hello " + name)
}
func input(prompt = ""){
print(prompt)
return readln()
}
name = input("name: ")
greet(name)
// comment
/*
block comment
*/
class Calc {
func Calc(a, op, b){
this.a = a
this.b = b
this.op = op
}
func calc() {
return this._calc(this.a, this.op, this.b)
}
func _calc(a, op, b){
return match (op){
case "+": a + b
case "-": a - b
case "*": a * b
case "/": a / b
case _: {
throw ValueError "Unsupported op: `" + op + "`"
}
}
}
}
a = random(1, 100)
b = random(1, 100)
op_chance = random(0, 40)
if (op_chance <= 10){
op = "+"
} else if (op_chance <= 20){
op = "-"
} else if (op_chance <= 30){
op = "*"
} else if (op_chance <= 40){
op = "/"
}
calc = new Calc(10, op, 50)
println(calc.calc())
arr = Array(10)
for (i : range(arr.length)){
arr[i] = random(1, 50)
}
for (i : arr){
print(str(i) + " ")
}
println("")