Add usable table/map stdlib with put, and show run bindings in view.
Authors can update nested collections via table.put/表.改 instead of json.set chains; view’s right rail adds collapsible Variables from the entry env. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
91d51f3f0a
commit
25b7be6739
26 files changed
+1577
-123
No files matched your search
@@ -1036,6 +1036,19 @@ fn lib_json_roundtrip() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_table_collections() {
|
||||
assert_out(
|
||||
"tests/lib/table-collections.mq.md",
|
||||
"Bearer-x\nA\nb\nhi\nTrue\n3\n[Authorization, role, content]\n0",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_table_collections_zh() {
|
||||
assert_out("tests/lib/表-集合.mq.md", "Bearer-x\nA\n3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_sys_cwd() {
|
||||
assert_out("tests/lib/sys-cwd.mq.md", "cwd-ok");
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
title: table collections
|
||||
description: put + list/map helpers
|
||||
> lib/table.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`h` = > table.put in=None at=Authorization value=Bearer-x*
|
||||
> print text=`h`[^Authorization]
|
||||
|
||||
`xs` =
|
||||
|
||||
| v |
|
||||
|---|
|
||||
| a |
|
||||
| b |
|
||||
|
||||
*`xs` = > table.put in=`xs` at=1 value=A*
|
||||
> print text=`xs`[^1]
|
||||
> print text=`xs`[^2]
|
||||
|
||||
`req` =
|
||||
|
||||
| model | messages |
|
||||
|-------|----------|
|
||||
| m1 | None |
|
||||
|
||||
*`msg` = > table.put in=None at=role value=user*
|
||||
*`msg` = > table.put in=`msg` at=content value=hi*
|
||||
*`messages` = > table.append list=None item=`msg`*
|
||||
*`req` = > table.put in=`req` at=messages value=`messages`*
|
||||
*`req` = > table.put in=`req` at=stream value=True*
|
||||
> print text=`req`[^messages][^1][^content]
|
||||
> print text=`req`[^stream]
|
||||
|
||||
*`xs` = > table.append list=`xs` item=c*
|
||||
*`n` = > table.len xs=`xs`*
|
||||
> print text=`n`
|
||||
|
||||
*`m` = > table.merge a=`h` b=`msg`*
|
||||
*`ks` = > table.keys map=`m`*
|
||||
> print text=`ks`
|
||||
|
||||
*`empty` = > table.empty_map*
|
||||
*`sz` = > table.size map=`empty`*
|
||||
> print text=`sz`
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: 表集合
|
||||
description: 改 + 列表字典
|
||||
> lib/表.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`h` = > 表.改 入=None 于=Authorization 值=Bearer-x*
|
||||
> 打印 内容=`h`[^Authorization]
|
||||
|
||||
`xs` =
|
||||
|
||||
| v |
|
||||
|---|
|
||||
| a |
|
||||
| b |
|
||||
|
||||
*`xs` = > 表.改 入=`xs` 于=1 值=A*
|
||||
> 打印 内容=`xs`[^1]
|
||||
|
||||
*`xs` = > 表.追加 list=`xs` item=c*
|
||||
*`n` = > 表.长度 xs=`xs`*
|
||||
> 打印 内容=`n`
|
||||
Reference in new issue
Block a user