Sow
例題
すべて開く すべて閉じる例 (4)
Reapが集めるように一部を「播いて」一連の式を評価する:
Reap[Sow[a];b;Sow[c];Sow[d];e]Reap[Sum[Sow[i ^ 2] + 1, {i, 10}]]Reap[Sow[1, x];Sow[2, y];Sow[3, x];Sow[4, y]]Reap[Sow[1, x];Sow[2, y];Sow[3, x];Sow[4, y], x]スコープ (5)
Sowは計算のどこで用いてもよい:
Reap[MapAll[If[PrimeQ[#], Sow[#]]&, Integrate[1 / (x ^ 5 - 1), x]];]f[e_] := If[PrimeQ[e], Sow[e]]Reap[MapAll[f, Integrate[1 / (x ^ 5 - 1), x]];]Reap[Sow[1, x];Sow[2, {x, y}];Sow[3, y]]Reap[Sow[1, {x, x, x}];Sow[2, {x, y}];Sow[3, y]]Reap中のパターンはどのタグを集めるかの指定に使うことができる:
Reap[Sow[1, x];Sow[2, {x, y}];Sow[3, {y, z}];Sow[4, {x, y, z}], x | y]Reap[Sow[1, x];Sow[2, {x, y}];Sow[3, {y, z}];Sow[4, {x, y, z}]]Reap[Sow[#, # > 0]& /@ {1, -1, 2, -3, 1, 4, 5};]Reap[Sow[#, # > 0]& /@ {1, -1, 2, -3, 1, 4, 5};, True]アプリケーション (3)
FindRootを評価するときに取られる全ステップのリストを作る:
Reap[FindRoot[Cos[x] == x, {x, 1}, StepMonitor :> Sow[x]]]1/100より下の反復はそのままにして,反復するマップを評価する:
Reap[Nest[(If[# < 1 / 100, Sow[#]];4 #(1 - #))&, 0.2, 100]]Reap[Do[Sow[i, Mod[i ^ 2, 10]], {i, 20}]]履歴
2003 で導入 (5.0)
テキスト
Wolfram Research (2003), Sow, Wolfram言語関数, https://reference.wolfram.com/language/ref/Sow.html.
CMS
Wolfram Language. 2003. "Sow." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Sow.html.
APA
Wolfram Language. (2003). Sow. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Sow.html
BibTeX
@misc{reference.wolfram_2026_sow, author="Wolfram Research", title="{Sow}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/Sow.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_sow, organization={Wolfram Research}, title={Sow}, year={2003}, url={https://reference.wolfram.com/language/ref/Sow.html}, note=[Accessed: 03-November-2026]}