File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -86,11 +86,11 @@ fn num_water_bottles(num_bottles: Int, num_exchange: Int) -> Int {
86
86
consume(num_bottles, 0)
87
87
}
88
88
89
- // 程序入口
90
- fn init {
89
+ // 程序测试
90
+ test {
91
91
// 命令
92
- assert (num_water_bottles(9, 3) == 13)
93
- assert (num_water_bottles(15, 4) == 19)
92
+ @assertion.assert_eq (num_water_bottles(9, 3), 13)?
93
+ @assertion.assert_eq (num_water_bottles(15, 4), 19)?
94
94
}
95
95
```
96
96
---
@@ -317,7 +317,7 @@ $\mapsto$ `15` 因为
317
317
``` moonbit
318
318
// 顶层(全局)即指定义在一个文件中所有表达式块外部定义的函数或标识符
319
319
let 顶层标识符 = 10
320
- fn 顶层函数(): Unit {
320
+ fn 顶层函数() -> Unit {
321
321
// 本地(局部)即指某个表达式块内部的函数或标识符
322
322
fn 本地函数() {
323
323
let 本地标识符 = 1 // 局部数值绑定可以简化
@@ -348,6 +348,8 @@ fn 顶层函数(): Unit {
348
348
- 对剩余表达式进行化简
349
349
350
350
``` moonbit expr
351
+ let y: Int = 10
352
+
351
353
let value = {
352
354
let x = 1
353
355
let tmp = x * 2
@@ -358,8 +360,6 @@ let value = {
358
360
}
359
361
tmp + another_tmp + y
360
362
}
361
-
362
- let y: Int = 10
363
363
```
364
364
365
365
---
@@ -372,6 +372,8 @@ let y: Int = 10
372
372
- 对剩余表达式进行化简
373
373
374
374
``` moonbit expr
375
+ let y: Int = 10
376
+
375
377
let value = {
376
378
let x = 1
377
379
let tmp = 1 * 2 // 替换x
@@ -382,8 +384,6 @@ let value = {
382
384
}
383
385
tmp + another_tmp + 10 // 替换y
384
386
}
385
-
386
- let y: Int = 10
387
387
```
388
388
389
389
---
@@ -396,6 +396,8 @@ let y: Int = 10
396
396
- 对剩余表达式进行化简
397
397
398
398
``` moonbit expr
399
+ // 省略y的定义
400
+
399
401
let value = {
400
402
// 省略x的定义
401
403
let tmp = 2 // 简化右侧表达式
@@ -406,8 +408,6 @@ let value = {
406
408
}
407
409
tmp + another_tmp + 10
408
410
}
409
-
410
- // 省略y的定义
411
411
```
412
412
413
413
---
You can’t perform that action at this time.
0 commit comments