-
Notifications
You must be signed in to change notification settings - Fork 0
/
oracle.aby
48 lines (43 loc) · 1.28 KB
/
oracle.aby
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
// シンプルな書き方
forge x: arcana = -5;
oracle {
(x > 0) => unveil("x is positive");
(x < 0) => unveil("x is negative");
_ => unveil("x is zero");
};
// 条件文にOmen型を使う場合
oracle (x > 0) {
(boon) => unveil("x is positive");
(hex) => unveil("x is negative or zero");
};
// 条件文にOmen型以外を使う場合
oracle (y = x ^ 2) {
(y > 100) => unveil("y is greater than 100");
(y == 100) => unveil("y is equal to 100");
_ => unveil("y is less than 100");
};
oracle (a = "abyss-lang") {
(a == "abyss") => unveil("a is abyss");
_ => unveil("a is not abyss");
};
// 条件文に複数の条件を使う場合
oracle (a = 3, b = 2) {
(a == 1 && b == 2) => unveil("a is 1 and b is 2");
(a != 1 && b == 2) => unveil("a is not 1 and b is 2");
(a == 1 && b != 2) => unveil("a is 1 and b is not 2");
_ => unveil("a is not 1 and b is not 2");
};
// xが正の場合xを表示、x + 5が正の場合x + 5を表示、それ以外の場合-999を表示
forge x: arcana = -10;
forge y: arcana = oracle (x > 0) {
(boon) => reveal x;
(hex) => {
forge z: arcana = x + 5;
reveal oracle (z > 0) {
(boon) => z;
(hex) => -999;
};
unveil("Not displayed");
}
};
unveil(y);