FoldList
范例
打开所有单元 关闭所有单元基本范例 (6)
FoldList[f, x, {a, b, c, d}]FoldList[Plus, 0, {a, b, c, d}]FoldList[#1 ^ #2&, x, {a, b, c, d}]FoldList[f, {a, b, c, d}]在一个参数中使用 FoldList 算子形式:
FoldList[f][{a, b, c, d}]在两个参数中使用 FoldList 算子形式:
FoldList[f][x, {a, b, c, d}]范围 (2)
推广和延伸 (2)
头部不一定是 List:
FoldList[f, x, p[a, b, c, d]]FoldList[g[#2, #1]&, x, {a, b, c, d}]应用 (15)
FoldList[Times, 1, Range[10]]FoldList[Times, 1, Array[Prime, 10]]FoldList[Plus, 0, {a, b, c, d}]FoldList[1 / (#2 + #1)&, x, Reverse[{a, b, c}]]FoldList[x #1 + #2&, 0, {a, b, c, d}]FoldList[10#1 + #2&, 0, {4, 5, 1, 6, 7, 8}]FoldList[#2 - #1&, 0, {a, b, c, d, e}]FoldList[Plus, 0, Table[(-1) ^ RandomInteger[], {20}]]FoldList[Max, 0, {1, 3, 1, 2, 4, 1, 5, 3, 6, 2, 8, 11}]DeleteDuplicates[%]FoldList[#1[[#2]]&, (a + b)(x ^ 2 + y ^ 2), {2, 1, 1}]FoldList[Part, (a + b)(x ^ 2 + y ^ 2), {2, 1, 1}]FoldList[Append, {x}, {a, b, c, d}]FoldList[List, x, {a, b, c, d}]FoldList[{#2, #1}&, x, {a, b, c, d}]FoldList[#2[#1]&, x, {a, b, c, d}]With[{m = x, t = 85}, FoldList[#1 ^ 2 m ^ #2&, 1, IntegerDigits[t, 2]]]With[{m = 3, t = 85}, FoldList[#1 ^ 2 m ^ #2&, 1, IntegerDigits[t, 2]]]属性和关系 (5)
FoldList 形成一个长度为
的列表:
Length[FoldList[f, x, Range[10]]]Rest 给出长度为
的结果:
Rest[FoldList[Plus, 0, {a, b, c, d, e}]]FoldList[f, x, {}]FoldList[f, x, {a, b, c}]Fold[f, x, {a, b, c}]忽略第二个自变量的函数给出与 NestList 中相同的结果:
FoldList[f[#1]&, x, Range[5]]NestList[f, x, 5]Accumulate 等价于带有 Plus 的 FoldList:
FoldList[Plus, {a, b, c, d}]Accumulate[{a, b, c, d}]可能存在的问题 (1)
技术笔记
-
▪
- 函数的重复调用
历史
1991年引入 (2.0) | 在以下年份被更新:2012 (9.0) ▪ 2016 (11.0)
文本
Wolfram Research (1991),FoldList,Wolfram 语言函数,https://reference.wolfram.com/language/ref/FoldList.html (更新于 2016 年).
CMS
Wolfram 语言. 1991. "FoldList." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2016. https://reference.wolfram.com/language/ref/FoldList.html.
APA
Wolfram 语言. (1991). FoldList. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/FoldList.html 年
BibTeX
@misc{reference.wolfram_2026_foldlist, author="Wolfram Research", title="{FoldList}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/FoldList.html}", note=[Accessed: 08-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_foldlist, organization={Wolfram Research}, title={FoldList}, year={2016}, url={https://reference.wolfram.com/language/ref/FoldList.html}, note=[Accessed: 08-November-2026]}