Files
marqdo/examples/code-as-docs/index.mq.md
T
cflmyandCursor abcb141737 refactor: prefer link-index get across examples and tests
Migrate remaining footnote-style collection access in examples,
public/structure, and ext/lib smokes to [key](base); teach link-index in
structure pages and use bracket calls in the cafe journal example.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 12:54:38 +08:00

87 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 代码即文档 · 周末咖啡手账
description: >-
一份可读可跑的周末手账:菜单是表,计价写在段落里,结账读起来像日记。
---
周六的咖啡馆手账——下面既是给人看的说明,也是可以 `marqdo run` 的程序。
**说明**性的加粗只是强调;真正算账的步骤也用粗体写在句子里,算完的值用斜体交回去。
---
## 单价
一杯标价为`价`的饮品,默认`杯数`=1。先把**总额 = 价 * 杯数**算清,再返回*总额*。
## 会员折
会员单要原价`原价`;店里默认八五折,记作`折扣`=0.85。
先算**应付 = 原价 * 折扣**,再返回*应付*。
## 结账摘要
客人点了`品名`,单价`价`,杯数`杯数`=1;是否`会员`=False。
按杯数问单价:**小计 = 单价 价=`价` 杯数=`杯数`**。
1. `会员`
**实付 = 会员折 原价=`小计`**
**标签 = "会员价"**
2. *
**实付 = 小计**
**标签 = "原价"**
对账时拼成一句人话:
**文案 = 品名 + " ×" + 杯数 + " → " + 标签 + " " + 实付**
*文案*
## 印章加一
积分卡上的`印`,每喝一杯就**印 = 印 + 1**,接着返回*印*。
# main
今日黑板价目——表格给人扫一眼,程序当字典用:
`菜单` =
| 美式 | 拿铁 | 燕麦拿铁 |
|------|------|----------|
| 18 | 28 | 32 |
---
上午来了位会员,点两杯拿铁。品名写进`名`,价钱从菜单里取:
**名 = "拿铁"**
**价 = [`名`](菜单)**
**摘要 = [结账摘要] 品名=`名` 价=`价` 杯数=2 会员=True**
**打印 内容=`摘要`**
旁桌只要一杯普通美式,对照一下原价:
**对照 = [结账摘要] 品名="美式" 价=[美式](菜单)**
**打印 内容=`对照`**
---
下午把外卖单抄成行表,一行一行结:
`今日订单` =
| @ | 品名 | 单价 | 杯数 | 会员 |
|---|------|------|------|------|
| 1 | 燕麦拿铁 | 32 | 1 | True |
| 2 | 美式 | 18 | 2 | False |
- [行](今日订单)
**一行 = 结账摘要 品名=[品名](行) 价=[单价](行) 杯数=[杯数](行) 会员=[会员](行)**
**打印 内容=`一行`**
打烊前给积分卡盖一个章:
**印 = 41**
**印 = 印章加一 印=`印`**
**打印 内容=`印`**