Sow

Sow[e]

specifies that e should be collected by the nearest enclosing Reap.

Sow[e,tag]

specifies that e should be collected by the nearest enclosing Reap whose pattern matches tag.

Sow[e,{tag1,tag2,}]

specifies that e should be collected once for each pattern that matches a tagi.

Details

  • Sow[e,] returns e.
  • By having several identical tagi, a single expression can be made to appear multiple times in a list returned by Reap.
  • Sow[e] is equivalent to Sow[e,None].
  • Sow[e,{{tag}}] sows an expression with tag {tag}.

Examples

open allclose all

Basic Examples  (4)

Evaluate a sequence of expressions, "sowing" some to be collected by Reap:

In[1]:=
Click for copyable input
Out[1]=

Compute a sum, "sowing" i^2 at each step:

In[1]:=
Click for copyable input
Out[1]=

Make separate lists for expressions "sown" with different tags:

In[1]:=
Click for copyable input
Out[1]=

Reap only expressions "sown" with tag x:

In[1]:=
Click for copyable input
Out[1]=

Scope  (5)

Applications  (3)

Properties & Relations  (2)

See Also

Reap  Throw  AppendTo  AskAppend  EvaluationMonitor  StepMonitor  Monitor  Scan

Tutorials

Introduced in 2003
(5.0)