feat(stdlib): Mid M5 list algorithms and cli.parse
Thicken table with sort/unique/chunk/zip/flatten and add lib/cli flag parsing, with golds and public demos. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
506de65dae
commit
7d86ed1d9c
20 files changed
+608
-14
No files matched your search
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
官方扩展(非 stdlib):`ext/llm`、`ext/agent`、`ext/web`、`ext/quantum`、`ext/linalg` — 见 `features/05-*.mq.md`、`06-*.mq.md`、`07-linalg.mq.md` / `07-线性代数.mq.md` 与 `doc/design/ext-*.md`。
|
||||
|
||||
中层标准库(Mid):`08-re-encoding` · `09-path-fs` · `10-hash-secrets` · `11-csv-text`(及对应中文页)。
|
||||
中层标准库(Mid):`08`–`12`(re/encoding · path/fs · hash/secrets · csv/text · list/cli;及对应中文页)。
|
||||
|
||||
**不放** `errors/`:失败样例只在 `tests/errors/`。
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Mid stdlib — lists and cli
|
||||
description: table sort/unique/zip + cli.parse (Mid M5)
|
||||
import table:lib/table.mq.md
|
||||
import csv:lib/csv.mq.md
|
||||
import cli:lib/cli.mq.md
|
||||
---
|
||||
|
||||
# Sort CSV rows and parse flags
|
||||
|
||||
Zero plugins: parse CSV, sort by key, parse `--input`.
|
||||
|
||||
# main
|
||||
|
||||
*raw = "name,score\nbob,2\nalice,10\n"*
|
||||
*rows = > csv.parse text=`raw`*
|
||||
*rows = > table.sort_by list=`rows` key="name"*
|
||||
*r0 = > at value=`rows` index=0*
|
||||
> print text=`r0`[^name]
|
||||
|
||||
*args = > split value="--input,scores.csv,--pretty" sep=","*
|
||||
*flags = > cli.parse args=`args`*
|
||||
> print text=`flags`[^input]
|
||||
1. `flags`[^pretty]
|
||||
> print text=mid-m5-ok
|
||||
2. *
|
||||
> print text=mid-m5-fail
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: 中层标准库 — 列表与命令行
|
||||
description: 表排序/去重 + 命令行解析(中层 M5)
|
||||
导入 表:lib/表.mq.md
|
||||
导入 逗号表:lib/逗号表.mq.md
|
||||
导入 命令行:lib/命令行.mq.md
|
||||
---
|
||||
|
||||
# 排序 CSV 并解析参数
|
||||
|
||||
零插件:解析 CSV、按键排序、解析 `--input`。
|
||||
|
||||
# main
|
||||
|
||||
*raw = "name,score\nbob,2\nalice,10\n"*
|
||||
*rows = > 逗号表.解析 内容=`raw`*
|
||||
*rows = > 表.按键排序 list=`rows` key="name"*
|
||||
*r0 = > at value=`rows` index=0*
|
||||
> 打印 内容=`r0`[^name]
|
||||
|
||||
*args = > split value="--input,scores.csv,--pretty" sep=","*
|
||||
*flags = > 命令行.解析 参数=`args`*
|
||||
> 打印 内容=`flags`[^input]
|
||||
1. `flags`[^pretty]
|
||||
> 打印 内容=mid-m5-ok
|
||||
2. *
|
||||
> 打印 内容=mid-m5-fail
|
||||
Reference in new issue
Block a user