Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > 核心语言 > 列表操作 > 重排列与重构列表 >
Mathematica > 数据处理 > 大型数组的处理 > 重排列与重构列表 >

GatherBy

GatherBy[list, f]
当应用 f,将 list 中每个集合中的元素根据值收集到子列表中。
GatherBy[list, {f1, f2, ...}]
在层 i 应用 fi 后,将 list 收集到嵌套列表中。
  • GatherBy[{e1, e2, e3, ...}, f] 计算 f[ei] ,对于每个 i 确定如何收集 ei
  • GatherBy[list, ...] 按照 list 中元素的顺序给出结果。
  • GatherBy[list, ...] 生成的每个子列表中, 元素的顺序和 list 中相同;对完整的子列表排序,这样第一个元素出现的顺序和 list 相同。
  • GatherBy 实际上产生一个等价的划分。
  • GatherBy[list, {f1, f2}] 等价于 Map[GatherBy[#, f2]&, GatherBy[list, f1]]
7 的新功能
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team