feat(stdlib): Mid M4 csv and thickened text helpers
Add lib/csv parse/stringify and expand lib/text with contains, replace, case, pad, and related golds plus public demos. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
08384c7540
commit
506de65dae
22 files changed
+766
-15
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`(及对应中文页)。
|
||||
中层标准库(Mid):`08-re-encoding` · `09-path-fs` · `10-hash-secrets` · `11-csv-text`(及对应中文页)。
|
||||
|
||||
**不放** `errors/`:失败样例只在 `tests/errors/`。
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: Mid stdlib — csv and text
|
||||
description: lib/csv + thickened lib/text (Mid M4)
|
||||
import csv:lib/csv.mq.md
|
||||
import text:lib/text.mq.md
|
||||
---
|
||||
|
||||
# CSV cleaning with text helpers
|
||||
|
||||
Parse a tiny CSV, normalize a field, print — no plugins.
|
||||
|
||||
# main
|
||||
|
||||
*raw = "name,city\nAda,london\nBob,PARIS\n"*
|
||||
*rows = > csv.parse text=`raw`*
|
||||
*r0 = > at value=`rows` index=0*
|
||||
*city = > text.to_upper text=`r0`[^city]*
|
||||
> print text=`r0`[^name]
|
||||
> print text=`city`
|
||||
*n = > len `rows`*
|
||||
1. `n` == 2
|
||||
> print text=mid-m4-ok
|
||||
2. *
|
||||
> print text=mid-m4-fail
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: 中层标准库 — 逗号表与文本
|
||||
description: lib/逗号表 + 加厚 lib/文本(中层 M4)
|
||||
导入 逗号表:lib/逗号表.mq.md
|
||||
导入 文本:lib/文本.mq.md
|
||||
---
|
||||
|
||||
# 用文本助手清洗 CSV
|
||||
|
||||
解析小表、规范化字段、打印 — 无需插件。
|
||||
|
||||
# main
|
||||
|
||||
*raw = "name,city\nAda,london\nBob,PARIS\n"*
|
||||
*rows = > 逗号表.解析 内容=`raw`*
|
||||
*r0 = > at value=`rows` index=0*
|
||||
*city = > 文本.大写 内容=`r0`[^city]*
|
||||
> 打印 内容=`r0`[^name]
|
||||
> 打印 内容=`city`
|
||||
*n = > 长度 `rows`*
|
||||
1. `n` == 2
|
||||
> 打印 内容=mid-m4-ok
|
||||
2. *
|
||||
> 打印 内容=mid-m4-fail
|
||||
Reference in new issue
Block a user