docs(lib): narrate table/text/json as code-as-docs pilot
Add purpose lines and bracket-call examples in EN/ZH libs and public/stdlib demos; keep explicit + params so function-body prose cannot be mistaken for link-index or bold code. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
0e0655b316
commit
53bc3538da
13 files changed
+238
-89
No files matched your search
+19
-1
@@ -1,33 +1,47 @@
|
||||
---
|
||||
title: lib/json
|
||||
description: JSON parse/stringify (shared EN/ZH import)
|
||||
description: JSON parse/stringify (shared EN/ZH import). Not a dict builder — use lib/table.
|
||||
---
|
||||
|
||||
Parse and stringify JSON. For maps/lists prefer GFM tables and lib/table put; do not chain json.set / json.append in new code.
|
||||
|
||||
## parse
|
||||
+ `text`
|
||||
|
||||
Parse JSON text into a Marqdo value.
|
||||
|
||||
Caller: [json.parse] text="{}"
|
||||
|
||||
*> host_json_parse text=`text`*
|
||||
|
||||
## stringify
|
||||
+ `value`
|
||||
+ `indent`=None
|
||||
|
||||
Serialize value to JSON text; optional indent.
|
||||
|
||||
*> host_json_stringify value=`value` indent=`indent`*
|
||||
|
||||
## get
|
||||
+ `value`
|
||||
+ `key`
|
||||
|
||||
Shallow get from JSON object value at key. Prefer link-index get or table.get in new code.
|
||||
|
||||
*> host_json_get value=`value` key=`key`*
|
||||
|
||||
## keys
|
||||
+ `value`
|
||||
|
||||
Keys of JSON object value.
|
||||
|
||||
*> host_json_keys value=`value`*
|
||||
|
||||
## quote
|
||||
+ `text`
|
||||
|
||||
JSON-quote string text (for building request bodies).
|
||||
|
||||
*> host_json_quote text=`text`*
|
||||
|
||||
## set
|
||||
@@ -35,10 +49,14 @@ description: JSON parse/stringify (shared EN/ZH import)
|
||||
+ `key`
|
||||
+ `value`
|
||||
|
||||
Compatibility shallow set. Prefer table.put / table.set.
|
||||
|
||||
*> host_map_set map=`map` key=`key` value=`value`*
|
||||
|
||||
## append
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
Compatibility append. Prefer table.append.
|
||||
|
||||
*> host_list_append list=`list` item=`item`*
|
||||
+63
-19
@@ -1,34 +1,44 @@
|
||||
---
|
||||
title: lib/table
|
||||
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.
|
||||
List and map helpers. Prefer put (1-based path, same nesting as link-index get);
|
||||
at/set_at/slice are 0-based. Use lib/json only for parse/stringify.
|
||||
---
|
||||
|
||||
List and map helpers. Prefer put for nested writes; authors should read with link-index get, not new footnote indexes.
|
||||
|
||||
## 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).
|
||||
Update one element of collection in at path at to value.
|
||||
|
||||
at is a text key, a 1-based list index, or a list of keys/indices (same nesting as link-index get).
|
||||
|
||||
Caller: [table.put] in=None at="Authorization" value="Bearer-x"
|
||||
|
||||
*> host_collection_put in=`in` at=`at` value=`value`*
|
||||
|
||||
## len
|
||||
+ `xs`
|
||||
|
||||
Length of list or map xs.
|
||||
|
||||
*> len `xs`*
|
||||
|
||||
## rows
|
||||
+ `xs`
|
||||
|
||||
Row count for list xs (alias of len).
|
||||
|
||||
*> len `xs`*
|
||||
|
||||
## at
|
||||
+ `xs`
|
||||
+ `i`
|
||||
|
||||
Index is zero-based (same as builtin `at`). Out of range → `None`.
|
||||
Zero-based index into xs at i (same as builtin at). Out of range → None.
|
||||
|
||||
*> at value=`xs` index=`i`*
|
||||
|
||||
@@ -36,24 +46,32 @@ Index is zero-based (same as builtin `at`). Out of range → `None`.
|
||||
+ `xs`
|
||||
+ `i`
|
||||
|
||||
Zero-based row from xs at i.
|
||||
|
||||
*> at value=`xs` index=`i`*
|
||||
|
||||
## append
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
Append item to list.
|
||||
|
||||
*> host_list_append list=`list` item=`item`*
|
||||
|
||||
## prepend
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
Prepend item to list.
|
||||
|
||||
*> host_list_prepend list=`list` item=`item`*
|
||||
|
||||
## concat
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
Concatenate lists a and b.
|
||||
|
||||
*> host_list_concat a=`a` b=`b`*
|
||||
|
||||
## insert
|
||||
@@ -61,7 +79,7 @@ Index is zero-based (same as builtin `at`). Out of range → `None`.
|
||||
+ `index`
|
||||
+ `item`
|
||||
|
||||
Index is zero-based (may insert at `len` to append).
|
||||
Insert item into list at zero-based index (may insert at len to append).
|
||||
|
||||
*> host_list_insert list=`list` index=`index` item=`item`*
|
||||
|
||||
@@ -70,7 +88,7 @@ Index is zero-based (may insert at `len` to append).
|
||||
+ `index`
|
||||
+ `item`
|
||||
|
||||
Zero-based replace. Prefer `put` with 1-based index for author-facing edits.
|
||||
Zero-based replace of list at index with item. Prefer put with a 1-based index for author-facing edits.
|
||||
|
||||
*> host_list_set_at list=`list` index=`index` item=`item`*
|
||||
|
||||
@@ -78,12 +96,14 @@ Zero-based replace. Prefer `put` with 1-based index for author-facing edits.
|
||||
+ `list`
|
||||
+ `index`
|
||||
|
||||
Remove zero-based index from list.
|
||||
|
||||
*> 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.
|
||||
Drop the last item of list (errors if empty). Use last first when you need the removed value.
|
||||
|
||||
**`n` = > len `list`**
|
||||
1. `n` > 0
|
||||
@@ -94,11 +114,15 @@ Drop the last item (errors if empty). Use `last` first when you need the removed
|
||||
## first
|
||||
+ `list`
|
||||
|
||||
First item of list.
|
||||
|
||||
*> host_list_first list=`list`*
|
||||
|
||||
## last
|
||||
+ `list`
|
||||
|
||||
Last item of list.
|
||||
|
||||
*> host_list_last list=`list`*
|
||||
|
||||
## slice
|
||||
@@ -106,7 +130,7 @@ Drop the last item (errors if empty). Use `last` first when you need the removed
|
||||
+ `start`
|
||||
+ `end`=None
|
||||
|
||||
Zero-based half-open range from `start` to `end`.
|
||||
Zero-based half-open slice of list from start to end.
|
||||
|
||||
*> host_list_slice list=`list` start=`start` end=`end`*
|
||||
|
||||
@@ -114,25 +138,29 @@ Zero-based half-open range from `start` to `end`.
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
Whether list contains item.
|
||||
|
||||
*> host_list_contains list=`list` item=`item`*
|
||||
|
||||
## index_of
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
Zero-based index or `None`.
|
||||
Zero-based index of item in list, or None.
|
||||
|
||||
*> host_list_index_of list=`list` item=`item`*
|
||||
|
||||
## reverse
|
||||
+ `list`
|
||||
|
||||
Reverse list.
|
||||
|
||||
*> host_list_reverse list=`list`*
|
||||
|
||||
## sort
|
||||
+ `list`
|
||||
|
||||
Ascending sort (int/num/text preferred).
|
||||
Ascending sort of list (int/num/text preferred).
|
||||
|
||||
*> host_list_sort list=`list`*
|
||||
|
||||
@@ -140,14 +168,14 @@ Ascending sort (int/num/text preferred).
|
||||
+ `list`
|
||||
+ `key`
|
||||
|
||||
Sort a list of maps by `key`.
|
||||
Sort a list of maps by field key.
|
||||
|
||||
*> host_list_sort_by list=`list` key=`key`*
|
||||
|
||||
## unique
|
||||
+ `list`
|
||||
|
||||
Stable unique (first wins).
|
||||
Stable unique of list (first wins).
|
||||
|
||||
*> host_list_unique list=`list`*
|
||||
|
||||
@@ -155,27 +183,29 @@ Stable unique (first wins).
|
||||
+ `list`
|
||||
+ `size`
|
||||
|
||||
Split list into chunks of size.
|
||||
|
||||
*> host_list_chunk list=`list` size=`size`*
|
||||
|
||||
## zip
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
Pairs until the shorter list ends.
|
||||
Pair lists a and b until the shorter ends.
|
||||
|
||||
*> host_list_zip a=`a` b=`b`*
|
||||
|
||||
## flatten
|
||||
+ `list`
|
||||
|
||||
One-level flatten.
|
||||
One-level flatten of list.
|
||||
|
||||
*> host_list_flatten list=`list`*
|
||||
|
||||
## clear
|
||||
+ `value`
|
||||
|
||||
Empty list or empty map (by type).
|
||||
Empty list or empty map for value (by type).
|
||||
|
||||
*> host_collection_clear value=`value`*
|
||||
|
||||
@@ -183,7 +213,7 @@ Empty list or empty map (by type).
|
||||
+ `map`
|
||||
+ `key`
|
||||
|
||||
Missing key → `None`.
|
||||
Shallow get from map at key. Missing → None. Prefer link-index get in author code.
|
||||
|
||||
*> host_map_get map=`map` key=`key`*
|
||||
|
||||
@@ -192,7 +222,7 @@ Missing key → `None`.
|
||||
+ `key`
|
||||
+ `value`
|
||||
|
||||
Shallow map update. Prefer `put` for nested paths.
|
||||
Shallow map update. Prefer put for nested paths.
|
||||
|
||||
*> host_map_set map=`map` key=`key` value=`value`*
|
||||
|
||||
@@ -200,28 +230,36 @@ Shallow map update. Prefer `put` for nested paths.
|
||||
+ `map`
|
||||
+ `key`
|
||||
|
||||
Delete key from map.
|
||||
|
||||
*> host_map_delete map=`map` key=`key`*
|
||||
|
||||
## has
|
||||
+ `map`
|
||||
+ `key`
|
||||
|
||||
Whether map has key.
|
||||
|
||||
*> host_map_has map=`map` key=`key`*
|
||||
|
||||
## keys
|
||||
+ `map`
|
||||
|
||||
Keys of map.
|
||||
|
||||
*> host_map_keys map=`map`*
|
||||
|
||||
## values
|
||||
+ `map`
|
||||
|
||||
Values of map.
|
||||
|
||||
*> host_map_values map=`map`*
|
||||
|
||||
## items
|
||||
+ `map`
|
||||
|
||||
Rows shaped as key/value maps.
|
||||
Key/value rows from map.
|
||||
|
||||
*> host_map_items map=`map`*
|
||||
|
||||
@@ -229,19 +267,25 @@ Rows shaped as key/value maps.
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
Right-hand keys win.
|
||||
Merge maps a and b (right-hand keys win).
|
||||
|
||||
*> host_map_merge a=`a` b=`b`*
|
||||
|
||||
## size
|
||||
+ `map`
|
||||
|
||||
Key count of map.
|
||||
|
||||
*> host_map_size map=`map`*
|
||||
|
||||
## empty_list
|
||||
|
||||
Empty list.
|
||||
|
||||
*> host_list_concat a=None b=None*
|
||||
|
||||
## empty_map
|
||||
|
||||
Empty map.
|
||||
|
||||
*> host_map_merge a=None b=None*
|
||||
+25
-3
@@ -1,41 +1,57 @@
|
||||
---
|
||||
title: lib/text
|
||||
description: Text helpers (Mid M4 thicken). Literal replace — use lib/re for regex.
|
||||
description: Text helpers (Mid M4). Literal replace — use lib/re for regex.
|
||||
---
|
||||
|
||||
Small text helpers. Prefer these over hand-rolled splits; regex belongs in lib/re.
|
||||
|
||||
## str_trim
|
||||
+ `s`
|
||||
|
||||
Trim ends of string s.
|
||||
|
||||
*> trim `s`*
|
||||
|
||||
## str_split
|
||||
+ `s`
|
||||
+ `sep`
|
||||
|
||||
Split string s on separator sep.
|
||||
|
||||
*> split value=`s` sep=`sep`*
|
||||
|
||||
## str_join
|
||||
+ `xs`
|
||||
+ `sep`
|
||||
|
||||
Join list xs with separator sep.
|
||||
|
||||
*> join value=`xs` sep=`sep`*
|
||||
|
||||
## contains
|
||||
+ `text`
|
||||
+ `sub`
|
||||
|
||||
Whether text contains substring sub.
|
||||
|
||||
Caller: [text.contains] text="hello" sub="ell"
|
||||
|
||||
*> host_text_contains text=`text` sub=`sub`*
|
||||
|
||||
## starts_with
|
||||
+ `text`
|
||||
+ `prefix`
|
||||
|
||||
Whether text starts with prefix.
|
||||
|
||||
*> host_text_starts_with text=`text` prefix=`prefix`*
|
||||
|
||||
## ends_with
|
||||
+ `text`
|
||||
+ `suffix`
|
||||
|
||||
Whether text ends with suffix.
|
||||
|
||||
*> host_text_ends_with text=`text` suffix=`suffix`*
|
||||
|
||||
## replace
|
||||
@@ -44,24 +60,30 @@ description: Text helpers (Mid M4 thicken). Literal replace — use lib/re for r
|
||||
+ `new`
|
||||
+ `count`=None
|
||||
|
||||
Literal substring replace (`count` optional).
|
||||
Literal replace in text: replace old with new, optional count.
|
||||
|
||||
*> host_text_replace text=`text` old=`old` new=`new` count=`count`*
|
||||
|
||||
## to_upper
|
||||
+ `text`
|
||||
|
||||
Uppercase text.
|
||||
|
||||
*> host_text_to_upper text=`text`*
|
||||
|
||||
## to_lower
|
||||
+ `text`
|
||||
|
||||
Lowercase text.
|
||||
|
||||
*> host_text_to_lower text=`text`*
|
||||
|
||||
## repeat
|
||||
+ `text`
|
||||
+ `n`
|
||||
|
||||
Repeat text n times.
|
||||
|
||||
*> host_text_repeat text=`text` n=`n`*
|
||||
|
||||
## pad
|
||||
@@ -70,6 +92,6 @@ Literal substring replace (`count` optional).
|
||||
+ `fill`=None
|
||||
+ `align`=None
|
||||
|
||||
align: left (default), right, or center.
|
||||
Pad text to width with fill and align (left / right / center).
|
||||
|
||||
*> host_text_pad text=`text` width=`width` fill=`fill` align=`align`*
|
||||
+24
-2
@@ -3,39 +3,55 @@ title: lib/文本
|
||||
description: 文本库加厚(中层 M4)。字面替换 — 正则请用 lib/正则。
|
||||
---
|
||||
|
||||
常用文本助手。手写拆分不如走这里;正则请用 lib/正则。
|
||||
|
||||
## 去空白
|
||||
+ `s`
|
||||
|
||||
去掉字符串 s 两端空白。
|
||||
|
||||
*> trim `s`*
|
||||
|
||||
## 拆分
|
||||
+ `s`
|
||||
+ `sep`
|
||||
|
||||
按分隔符 sep 拆分字符串 s。
|
||||
|
||||
*> split value=`s` sep=`sep`*
|
||||
|
||||
## 拼接
|
||||
+ `xs`
|
||||
+ `sep`
|
||||
|
||||
用分隔符 sep 拼接列表 xs。
|
||||
|
||||
*> join value=`xs` sep=`sep`*
|
||||
|
||||
## 包含
|
||||
+ `内容`
|
||||
+ `子串`
|
||||
|
||||
内容是否包含子串。
|
||||
|
||||
调用例:[文本.包含] 内容="你好" 子串="好"
|
||||
|
||||
*> host_text_contains text=`内容` sub=`子串`*
|
||||
|
||||
## 开头是
|
||||
+ `内容`
|
||||
+ `前缀`
|
||||
|
||||
内容是否以前缀开头。
|
||||
|
||||
*> host_text_starts_with text=`内容` prefix=`前缀`*
|
||||
|
||||
## 结尾是
|
||||
+ `内容`
|
||||
+ `后缀`
|
||||
|
||||
内容是否以后缀结尾。
|
||||
|
||||
*> host_text_ends_with text=`内容` suffix=`后缀`*
|
||||
|
||||
## 替换
|
||||
@@ -44,24 +60,30 @@ description: 文本库加厚(中层 M4)。字面替换 — 正则请用 lib/
|
||||
+ `新`
|
||||
+ `次数`=None
|
||||
|
||||
字面子串替换(可选 `次数`)。
|
||||
在内容里把字面旧换成新,可选次数。
|
||||
|
||||
*> host_text_replace text=`内容` old=`旧` new=`新` count=`次数`*
|
||||
|
||||
## 大写
|
||||
+ `内容`
|
||||
|
||||
内容转大写。
|
||||
|
||||
*> host_text_to_upper text=`内容`*
|
||||
|
||||
## 小写
|
||||
+ `内容`
|
||||
|
||||
内容转小写。
|
||||
|
||||
*> host_text_to_lower text=`内容`*
|
||||
|
||||
## 重复
|
||||
+ `内容`
|
||||
+ `次数`
|
||||
|
||||
把内容重复次数遍。
|
||||
|
||||
*> host_text_repeat text=`内容` n=`次数`*
|
||||
|
||||
## 填充
|
||||
@@ -70,6 +92,6 @@ description: 文本库加厚(中层 M4)。字面替换 — 正则请用 lib/
|
||||
+ `填充符`=None
|
||||
+ `对齐`=None
|
||||
|
||||
对齐:left(默认)/ right / center。
|
||||
把内容填充到宽度,可选填充符与对齐(left / right / center)。
|
||||
|
||||
*> host_text_pad text=`内容` width=`宽度` fill=`填充符` align=`对齐`*
|
||||
+63
-17
@@ -1,34 +1,44 @@
|
||||
---
|
||||
title: lib/表
|
||||
description: >-
|
||||
列表与字典。优先用「改」(路径 1-based,与脚注同构);取/改位/切片为 0-based。
|
||||
列表与字典。优先用「改」(路径 1-based,与链接取元同构);取/改位/切片为 0-based。
|
||||
json 只管解析/序列化。
|
||||
---
|
||||
|
||||
列表与字典。嵌套写入优先「改」;作者程序里读元用链接取元,不要新写脚注取元。
|
||||
|
||||
## 改
|
||||
+ `入`
|
||||
+ `于`
|
||||
+ `值`
|
||||
|
||||
直接改某一元。`于=` 为文本键、1-based 下标,或键/下标组成的路径列表(与脚注嵌套同构)。
|
||||
把集合入在路径于上的那一元改成值。
|
||||
|
||||
于可以是文本键、1-based 下标,或键/下标组成的路径列表(与链接取元嵌套同构)。
|
||||
|
||||
调用例:[表.改] 入=None 于="Authorization" 值="Bearer-x"
|
||||
|
||||
*> host_collection_put in=`入` at=`于` value=`值`*
|
||||
|
||||
## 长度
|
||||
+ `xs`
|
||||
|
||||
列表或字典 xs 的长度。
|
||||
|
||||
*> len `xs`*
|
||||
|
||||
## 行数
|
||||
+ `xs`
|
||||
|
||||
列表 xs 的行数(同长度)。
|
||||
|
||||
*> len `xs`*
|
||||
|
||||
## 取
|
||||
+ `xs`
|
||||
+ `i`
|
||||
|
||||
下标从零起(与内置 `at` 相同)。越界 → `None`。
|
||||
从零起取 xs 的第 i 项(与内置 at 相同)。越界 → None。
|
||||
|
||||
*> at value=`xs` index=`i`*
|
||||
|
||||
@@ -36,24 +46,32 @@ description: >-
|
||||
+ `xs`
|
||||
+ `i`
|
||||
|
||||
从零起取 xs 的第 i 行。
|
||||
|
||||
*> at value=`xs` index=`i`*
|
||||
|
||||
## 追加
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
在 list 末尾追加 item。
|
||||
|
||||
*> host_list_append list=`list` item=`item`*
|
||||
|
||||
## 前插
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
在 list 开头插入 item。
|
||||
|
||||
*> host_list_prepend list=`list` item=`item`*
|
||||
|
||||
## 拼接
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
拼接列表 a 与 b。
|
||||
|
||||
*> host_list_concat a=`a` b=`b`*
|
||||
|
||||
## 插入
|
||||
@@ -61,7 +79,7 @@ description: >-
|
||||
+ `index`
|
||||
+ `item`
|
||||
|
||||
下标从零起。
|
||||
在 list 的从零起 index 处插入 item。
|
||||
|
||||
*> host_list_insert list=`list` index=`index` item=`item`*
|
||||
|
||||
@@ -70,7 +88,7 @@ description: >-
|
||||
+ `index`
|
||||
+ `item`
|
||||
|
||||
从零起替换;日常嵌套改写请用「改」。
|
||||
从零起替换 list 的 index 为 item;日常嵌套改写请用「改」。
|
||||
|
||||
*> host_list_set_at list=`list` index=`index` item=`item`*
|
||||
|
||||
@@ -78,12 +96,14 @@ description: >-
|
||||
+ `list`
|
||||
+ `index`
|
||||
|
||||
删去 list 从零起的 index。
|
||||
|
||||
*> host_list_remove_at list=`list` index=`index`*
|
||||
|
||||
## 弹出
|
||||
+ `list`
|
||||
|
||||
去掉末项(空表报错)。需要末值时先「末」。
|
||||
去掉 list 末项(空表报错)。需要末值时先「末」。
|
||||
|
||||
**`n` = > len `list`**
|
||||
1. `n` > 0
|
||||
@@ -94,11 +114,15 @@ description: >-
|
||||
## 首
|
||||
+ `list`
|
||||
|
||||
list 的首项。
|
||||
|
||||
*> host_list_first list=`list`*
|
||||
|
||||
## 末
|
||||
+ `list`
|
||||
|
||||
list 的末项。
|
||||
|
||||
*> host_list_last list=`list`*
|
||||
|
||||
## 切片
|
||||
@@ -106,7 +130,7 @@ description: >-
|
||||
+ `start`
|
||||
+ `end`=None
|
||||
|
||||
从零起的半开区间,从 `start` 到 `end`。
|
||||
对 list 做从零起的半开切片,从 start 到 end。
|
||||
|
||||
*> host_list_slice list=`list` start=`start` end=`end`*
|
||||
|
||||
@@ -114,25 +138,29 @@ description: >-
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
list 是否含有 item。
|
||||
|
||||
*> host_list_contains list=`list` item=`item`*
|
||||
|
||||
## 下标
|
||||
+ `list`
|
||||
+ `item`
|
||||
|
||||
从零起的下标;没有 → `None`。
|
||||
item 在 list 中从零起的下标;没有 → None。
|
||||
|
||||
*> host_list_index_of list=`list` item=`item`*
|
||||
|
||||
## 反转
|
||||
+ `list`
|
||||
|
||||
反转 list。
|
||||
|
||||
*> host_list_reverse list=`list`*
|
||||
|
||||
## 排序
|
||||
+ `list`
|
||||
|
||||
升序(优先 int/num/text)。
|
||||
对 list 升序排序(优先 int/num/text)。
|
||||
|
||||
*> host_list_sort list=`list`*
|
||||
|
||||
@@ -140,14 +168,14 @@ description: >-
|
||||
+ `list`
|
||||
+ `key`
|
||||
|
||||
对 map 列表按键排序。
|
||||
对 map 列表 list 按字段 key 排序。
|
||||
|
||||
*> host_list_sort_by list=`list` key=`key`*
|
||||
|
||||
## 去重
|
||||
+ `list`
|
||||
|
||||
保序去重(保留首次)。
|
||||
对 list 保序去重(保留首次)。
|
||||
|
||||
*> host_list_unique list=`list`*
|
||||
|
||||
@@ -155,33 +183,37 @@ description: >-
|
||||
+ `list`
|
||||
+ `size`
|
||||
|
||||
把 list 按 size 分块。
|
||||
|
||||
*> host_list_chunk list=`list` size=`size`*
|
||||
|
||||
## 拉链
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
取较短长度配对。
|
||||
将 a 与 b 配对,取较短长度。
|
||||
|
||||
*> host_list_zip a=`a` b=`b`*
|
||||
|
||||
## 展平
|
||||
+ `list`
|
||||
|
||||
一层展平。
|
||||
对 list 做一层展平。
|
||||
|
||||
*> host_list_flatten list=`list`*
|
||||
|
||||
## 清空
|
||||
+ `value`
|
||||
|
||||
按类型清空 value(空列表或空字典)。
|
||||
|
||||
*> host_collection_clear value=`value`*
|
||||
|
||||
## 取键
|
||||
+ `map`
|
||||
+ `key`
|
||||
|
||||
缺键 → `None`。
|
||||
浅取 map 的 key;缺键 → None。作者侧优先链接取元。
|
||||
|
||||
*> host_map_get map=`map` key=`key`*
|
||||
|
||||
@@ -190,7 +222,7 @@ description: >-
|
||||
+ `key`
|
||||
+ `value`
|
||||
|
||||
浅层设键;嵌套请用「改」。
|
||||
浅设 map 的 key 为 value;嵌套请用「改」。
|
||||
|
||||
*> host_map_set map=`map` key=`key` value=`value`*
|
||||
|
||||
@@ -198,28 +230,36 @@ description: >-
|
||||
+ `map`
|
||||
+ `key`
|
||||
|
||||
从 map 删除 key。
|
||||
|
||||
*> host_map_delete map=`map` key=`key`*
|
||||
|
||||
## 有键
|
||||
+ `map`
|
||||
+ `key`
|
||||
|
||||
map 是否有 key。
|
||||
|
||||
*> host_map_has map=`map` key=`key`*
|
||||
|
||||
## 键表
|
||||
+ `map`
|
||||
|
||||
map 的键表。
|
||||
|
||||
*> host_map_keys map=`map`*
|
||||
|
||||
## 值表
|
||||
+ `map`
|
||||
|
||||
map 的值表。
|
||||
|
||||
*> host_map_values map=`map`*
|
||||
|
||||
## 项表
|
||||
+ `map`
|
||||
|
||||
键值对行表。
|
||||
map 的键值对行表。
|
||||
|
||||
*> host_map_items map=`map`*
|
||||
|
||||
@@ -227,19 +267,25 @@ description: >-
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
右侧覆盖左侧。
|
||||
合并 a 与 b(右侧覆盖左侧)。
|
||||
|
||||
*> host_map_merge a=`a` b=`b`*
|
||||
|
||||
## 键数
|
||||
+ `map`
|
||||
|
||||
map 的键数。
|
||||
|
||||
*> host_map_size map=`map`*
|
||||
|
||||
## 空表
|
||||
|
||||
空列表。
|
||||
|
||||
*> host_list_concat a=None b=None*
|
||||
|
||||
## 空字典
|
||||
|
||||
空字典。
|
||||
|
||||
*> host_map_merge a=None b=None*
|
||||
Reference in new issue
Block a user