FoldPairList[f,y0,{a1,a2,…}]
f を形式{yi-1,ai}のペアに適用した結果得られた連続する xiのリストを与える.各ステップで f は{xi,yi}を返す.
FoldPairList[f,y0,list,g]
g[{xi,yi}]の連続する値のリストを与える.
FoldPairList[f,{a0,a1,a2,…}]
FoldPairList[f,a0,{a1,a2,…}]に等しい.
FoldPairList
FoldPairList[f,y0,{a1,a2,…}]
f を形式{yi-1,ai}のペアに適用した結果得られた連続する xiのリストを与える.各ステップで f は{xi,yi}を返す.
FoldPairList[f,y0,list,g]
g[{xi,yi}]の連続する値のリストを与える.
FoldPairList[f,{a0,a1,a2,…}]
FoldPairList[f,a0,{a1,a2,…}]に等しい.
詳細
- FoldPairList[f,y0,list]中の関数 f は,常に2つの引数を取り,式のペア{x,y}を返すと期待される.
- FoldPairList[f,y0,expr]中の式 expr は,任意の頭部を持つ原子的ではない任意の式でよい.
- FoldPairList[f,y0,list]はFoldPairList[f,y0,list,First]に等しい.
- FoldPairList[f,y0,{a1,…,an}]は長さ n のリストを返す.FoldPairList[f,y0,{}]は{}を返す.
- Throwを使って終了前にFoldPairListから出ることができる.
例題
すべて開く すべて閉じる例 (6)
ペアを返す関数をシード u とリストの要素に連続的に適用し,ペアの第1要素を返す:
FoldPairList[{p[#1, #2], q[#1, #2]}&, u, {1, 2, 3, 4}]ペアを返す関数をシード u とリストの要素に連続的に適用し,次に関数 g をそのペアに適用する:
FoldPairList[{p[#1, #2], q[#1, #2]}&, u, {1, 2, 3}, g]シードと要素のリストをシードが第1要素の単一のリストとして与える:
FoldPairList[{p[#1, #2], q[#1, #2]}&, {a, b, c}]Listは,ペアを返す関数として使うことができる:
FoldPairList[List, 0, {1, 2, 3, 4}, g]FoldPairList[TakeDrop, {a, b, c, d, e, f}, {1, 3, 2}]FoldPairList[QuotientRemainder, 498, {100, 50, 20, 5, 1}]FoldPairList[QuotientRemainder, 498, {100, 50, 20, 5, 1}, Identity]スコープ (2)
FoldPairList[TakeDrop, {a, b, c, d, e, f}, {1, 3, 2}]FoldPairList[TakeDrop, {a, b, c, d, e, f}, h[1, 3, 2]]デフォルトで,FoldPairListはペアの最初の要素しか返さない:
FoldPairList[QuotientRemainder, 498, {100, 50, 20, 5}]FoldPairListを第4引数Lastとともに使い,連続するペアの第2要素を得る:
FoldPairList[QuotientRemainder, 498, {100, 50, 20, 5}, Last]一般化と拡張 (1)
Throwを使ってFoldPairListから出る:
FoldPairList[{#1 > 1000, #1 #2}&, 1, Range[10]]Catch[FoldPairList[{If[#1 > 1000, Throw[#1]], #1 #2}&, 1, Range[10]]]アプリケーション (2)
特性と関係 (4)
FoldPairList[List, u, {1, 2, 3, 4}]FoldPairList[List, u, {1, 2, 3, 4}, Last]array = Array[a, {2, 1, 4, 3}];FoldPairList[{Length[#], First[#]}&, array, Range[3]]% === Dimensions[array, 3]FoldPairは,FoldPairListによって返されるリストの最後の要素を返す:
FoldPairList[QuotientRemainder, 498, {100, 50, 20, 5, 1}]FoldPair[QuotientRemainder, 498, {100, 50, 20, 5, 1}]FoldPairListはFoldListより1少ない要素を返す:
FoldList[f[#1, #2]&, u, {a, b, c}]FoldPairList[{#, f[#1, #2]}&, u, {a, b, c}]FoldPairList[{#, f[#1, #2]}&, u, {a, b, c}, Last]考えられる問題 (2)
FoldPairListの第1引数中の関数は,式のペアを返さなければならない:
FoldPairList[MinMax[{#1, #2}]&, 10, {1, 20, 3, 25, 4, 30}]FoldPairList[Min, 10, {1, 20, 3, 25, 4, 30}]FoldPairList[f,y0,{}]は,最終要素のない空リストを返す:
FoldPairList[f, y0, {}]したがって,FoldPair[f,y0,{}]は未評価のままになる:
FoldPair[f, y0, {}]関連するガイド
-
▪
- 関数反復
テキスト
Wolfram Research (2015), FoldPairList, Wolfram言語関数, https://reference.wolfram.com/language/ref/FoldPairList.html.
CMS
Wolfram Language. 2015. "FoldPairList." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FoldPairList.html.
APA
Wolfram Language. (2015). FoldPairList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FoldPairList.html
BibTeX
@misc{reference.wolfram_2026_foldpairlist, author="Wolfram Research", title="{FoldPairList}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/FoldPairList.html}", note=[Accessed: 12-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_foldpairlist, organization={Wolfram Research}, title={FoldPairList}, year={2015}, url={https://reference.wolfram.com/language/ref/FoldPairList.html}, note=[Accessed: 12-November-2026]}