px普贤教程PuXian
普贤教程 › 包参考

collections 包

collections

collections

项值
包名collections
版本0.2.0
可用版本0.1.0 / 0.2.0
入口collections.px
分类数据结构
文件数 / 行数1 / 89

安装与引入

bash
pxpkg init          # 首次
pxpkg add collections@0.2.0
pxpkg install
px
import collections
所属分类教程:数据结构

公开接口

函数参数
uniqueitems
flattenitems
其余 5 个 def(内部与辅助,可直接调用但不属稳定接口)
函数参数
eachitems, f
zip_listsa, b
chunkitems, n
group_byitems, key_fn
sort_byitems, key_fn

包内说明(源码头注释)

text
# 普贤标准库:std.collections(集合操作)
# 本文件由普贤语言编写,脚本模式 / 编译模式双端共享(M5 自举验证)
# 依赖 builtin:map / filter / reduce / sorted / len / contains / type / str
# 用法:
#   import std.collections
#   或 from std.collections import unique, flatten
# 注意:参数名不用 fn(fn 是匿名函数关键字,避免解析歧义),用 f
# 遍历列表并对每个元素执行 f(无返回值)