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:
cflmyandCursor committed 2026-08-12 11:49:48 +08:00
1 parent 91d51f3f0a
commit 25b7be6739
26 files changed
+1577 -123

No files matched your search

+190 -1
View File
@@ -1,15 +1,204 @@
---
title: lib/table
description: English list helpers over len / at (prefer footnote index for one-shots)
description: >-
List and map helpers. Prefer put (1-based path, same as footnotes); at/set_at/slice
are 0-based. json is for parse/stringify.
---
## put
+ `in`
+ `at`
+ `value`
Directly update one element. `at=` is a text key, a **1-based** list index, or a list path of keys/indices (same nesting as footnotes).
**> host_collection_put in=`in` at=`at` value=`value`**
## len
+ `xs`
**> len `xs`**
## rows
+ `xs`
**> len `xs`**
## at
+ `xs`
+ `i`
Index is zero-based (same as builtin `at`). Out of range → `None`.
**> at value=`xs` index=`i`**
## row_at
+ `xs`
+ `i`
**> at value=`xs` index=`i`**
## append
+ `list`
+ `item`
**> host_list_append list=`list` item=`item`**
## prepend
+ `list`
+ `item`
**> host_list_prepend list=`list` item=`item`**
## concat
+ `a`
+ `b`
**> host_list_concat a=`a` b=`b`**
## insert
+ `list`
+ `index`
+ `item`
Index is zero-based (may insert at `len` to append).
**> host_list_insert list=`list` index=`index` item=`item`**
## set_at
+ `list`
+ `index`
+ `item`
Zero-based replace. Prefer `put` with 1-based index for author-facing edits.
**> host_list_set_at list=`list` index=`index` item=`item`**
## remove_at
+ `list`
+ `index`
**> host_list_remove_at list=`list` index=`index`**
## pop
+ `list`
Drop the last item (errors if empty). Use `last` first when you need the removed value.
*`n` = > len `list`*
1. `n` > 0
**> host_list_remove_at list=`list` index=`n` - 1**
2. *
**> host_list_remove_at list=`list` index=0**
## first
+ `list`
**> host_list_first list=`list`**
## last
+ `list`
**> host_list_last list=`list`**
## slice
+ `list`
+ `start`
+ `end`=None
Zero-based half-open range from `start` to `end`.
**> host_list_slice list=`list` start=`start` end=`end`**
## contains
+ `list`
+ `item`
**> host_list_contains list=`list` item=`item`**
## index_of
+ `list`
+ `item`
Zero-based index or `None`.
**> host_list_index_of list=`list` item=`item`**
## reverse
+ `list`
**> host_list_reverse list=`list`**
## clear
+ `value`
Empty list or empty map (by type).
**> host_collection_clear value=`value`**
## get
+ `map`
+ `key`
Missing key → `None`.
**> host_map_get map=`map` key=`key`**
## set
+ `map`
+ `key`
+ `value`
Shallow map update. Prefer `put` for nested paths.
**> host_map_set map=`map` key=`key` value=`value`**
## delete
+ `map`
+ `key`
**> host_map_delete map=`map` key=`key`**
## has
+ `map`
+ `key`
**> host_map_has map=`map` key=`key`**
## keys
+ `map`
**> host_map_keys map=`map`**
## values
+ `map`
**> host_map_values map=`map`**
## items
+ `map`
Rows shaped as key/value maps.
**> host_map_items map=`map`**
## merge
+ `a`
+ `b`
Right-hand keys win.
**> host_map_merge a=`a` b=`b`**
## size
+ `map`
**> host_map_size map=`map`**
## empty_list
**> host_list_concat a=None b=None**
## empty_map
**> host_map_merge a=None b=None**
+188 -1
View File
@@ -1,15 +1,202 @@
---
title: lib/表
description: 中文表库:行数 / 取行
description: >-
列表与字典。优先用「改」(路径 1-based,与脚注同构);取/改位/切片为 0-based。
json 只管解析/序列化。
---
## 改
+ `入`
+ `于`
+ `值`
直接改某一元。`于=` 为文本键、**1-based** 下标,或键/下标组成的路径列表(与脚注嵌套同构)。
**> host_collection_put in=`入` at=`于` value=`值`**
## 长度
+ `xs`
**> len `xs`**
## 行数
+ `xs`
**> len `xs`**
## 取
+ `xs`
+ `i`
下标从零起(与内置 `at` 相同)。越界 → `None`。
**> at value=`xs` index=`i`**
## 取行
+ `xs`
+ `i`
**> at value=`xs` index=`i`**
## 追加
+ `list`
+ `item`
**> host_list_append list=`list` item=`item`**
## 前插
+ `list`
+ `item`
**> host_list_prepend list=`list` item=`item`**
## 拼接
+ `a`
+ `b`
**> host_list_concat a=`a` b=`b`**
## 插入
+ `list`
+ `index`
+ `item`
下标从零起。
**> host_list_insert list=`list` index=`index` item=`item`**
## 改位
+ `list`
+ `index`
+ `item`
从零起替换;日常嵌套改写请用「改」。
**> host_list_set_at list=`list` index=`index` item=`item`**
## 删位
+ `list`
+ `index`
**> host_list_remove_at list=`list` index=`index`**
## 弹出
+ `list`
去掉末项(空表报错)。需要末值时先「末」。
*`n` = > len `list`*
1. `n` > 0
**> host_list_remove_at list=`list` index=`n` - 1**
2. *
**> host_list_remove_at list=`list` index=0**
## 首
+ `list`
**> host_list_first list=`list`**
## 末
+ `list`
**> host_list_last list=`list`**
## 切片
+ `list`
+ `start`
+ `end`=None
从零起的半开区间,从 `start` 到 `end`。
**> host_list_slice list=`list` start=`start` end=`end`**
## 含有
+ `list`
+ `item`
**> host_list_contains list=`list` item=`item`**
## 下标
+ `list`
+ `item`
从零起的下标;没有 → `None`。
**> host_list_index_of list=`list` item=`item`**
## 反转
+ `list`
**> host_list_reverse list=`list`**
## 清空
+ `value`
**> host_collection_clear value=`value`**
## 取键
+ `map`
+ `key`
缺键 → `None`。
**> host_map_get map=`map` key=`key`**
## 设
+ `map`
+ `key`
+ `value`
浅层设键;嵌套请用「改」。
**> host_map_set map=`map` key=`key` value=`value`**
## 删键
+ `map`
+ `key`
**> host_map_delete map=`map` key=`key`**
## 有键
+ `map`
+ `key`
**> host_map_has map=`map` key=`key`**
## 键表
+ `map`
**> host_map_keys map=`map`**
## 值表
+ `map`
**> host_map_values map=`map`**
## 项表
+ `map`
键值对行表。
**> host_map_items map=`map`**
## 合并
+ `a`
+ `b`
右侧覆盖左侧。
**> host_map_merge a=`a` b=`b`**
## 键数
+ `map`
**> host_map_size map=`map`**
## 空表
**> host_list_concat a=None b=None**
## 空字典
**> host_map_merge a=None b=None**