marqdo

05-loopok

structure/05-loop.mq.md

Structure

fn · h1main
comment

函数体内的 - 是循环(不是形参)。

comment

倒数:

bind`n` = 3
while`n` > 0
call> print text=`n`
bind`n` = `n` - 1
comment

遍历篮子(表格是集合):

bind`篮子` = [苹果, 梨]
foreach[果](篮子)
call> print text=今天吃`果`

Execution

3 2 1 今天吃苹果 今天吃梨

Source

---
title: 循环
description: 条件循环与表格遍历
---

# main

函数体内的 `-` 是循环(不是形参)。

倒数:

*`n` = 3*

- `n` > 0
  > print text=`n`
  *`n` = `n` - 1*

遍历篮子(表格是集合):

`篮子` =

| 果 |
|----|
| 苹果 |
| 梨 |

- [果](篮子)
  > print text=今天吃`果`